{"action":"created","issue":{"url":"https://api.github.com/repos/palkan/action_policy/issues/17","repository_url":"https://api.github.com/repos/palkan/action_policy","labels_url":"https://api.github.com/repos/palkan/action_policy/issues/17/labels{/name}","comments_url":"https://api.github.com/repos/palkan/action_policy/issues/17/comments","events_url":"https://api.github.com/repos/palkan/action_policy/issues/17/events","html_url":"https://github.com/palkan/action_policy/issues/17","id":333727239,"node_id":"MDU6SXNzdWUzMzM3MjcyMzk=","number":17,"title":"Best practice for authorising Rails controller methods without a model","user":{"login":"jacobwalkr","id":2103207,"node_id":"MDQ6VXNlcjIxMDMyMDc=","avatar_url":"https://avatars2.githubusercontent.com/u/2103207?v=4","gravatar_id":"","url":"https://api.github.com/users/jacobwalkr","html_url":"https://github.com/jacobwalkr","followers_url":"https://api.github.com/users/jacobwalkr/followers","following_url":"https://api.github.com/users/jacobwalkr/following{/other_user}","gists_url":"https://api.github.com/users/jacobwalkr/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobwalkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobwalkr/subscriptions","organizations_url":"https://api.github.com/users/jacobwalkr/orgs","repos_url":"https://api.github.com/users/jacobwalkr/repos","events_url":"https://api.github.com/users/jacobwalkr/events{/privacy}","received_events_url":"https://api.github.com/users/jacobwalkr/received_events","type":"User","site_admin":false},"labels":[{"id":908706616,"node_id":"MDU6TGFiZWw5MDg3MDY2MTY=","url":"https://api.github.com/repos/palkan/action_policy/labels/discussion","name":"discussion","color":"8f48d6","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2018-06-19T15:37:00Z","updated_at":"2018-06-20T09:30:31Z","closed_at":null,"author_association":"NONE","body":"We have a number of Rails controllers that are not directly tied to a model. For example, in our app, the AdminController does not have a corresponding Admin model and the StaffController links ultimately to the User model. In these instances, we can use something like `authorize! with: AdminPolicy` to specify.\r\n\r\nIs there a way to do this more tidily, without using `with:`? For example, by falling back on a policy that matches the controller name instead of a model name? \r\n\r\nWe've tried to do it by adding a custom probe to the lookup chain, but the `record` in these cases is `nil` and we can't find a robust way of accessing the controller name from the probe."},"comment":{"url":"https://api.github.com/repos/palkan/action_policy/issues/comments/398686005","html_url":"https://github.com/palkan/action_policy/issues/17#issuecomment-398686005","issue_url":"https://api.github.com/repos/palkan/action_policy/issues/17","id":398686005,"node_id":"MDEyOklzc3VlQ29tbWVudDM5ODY4NjAwNQ==","user":{"login":"jacobwalkr","id":2103207,"node_id":"MDQ6VXNlcjIxMDMyMDc=","avatar_url":"https://avatars2.githubusercontent.com/u/2103207?v=4","gravatar_id":"","url":"https://api.github.com/users/jacobwalkr","html_url":"https://github.com/jacobwalkr","followers_url":"https://api.github.com/users/jacobwalkr/followers","following_url":"https://api.github.com/users/jacobwalkr/following{/other_user}","gists_url":"https://api.github.com/users/jacobwalkr/gists{/gist_id}","starred_url":"https://api.github.com/users/jacobwalkr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jacobwalkr/subscriptions","organizations_url":"https://api.github.com/users/jacobwalkr/orgs","repos_url":"https://api.github.com/users/jacobwalkr/repos","events_url":"https://api.github.com/users/jacobwalkr/events{/privacy}","received_events_url":"https://api.github.com/users/jacobwalkr/received_events","type":"User","site_admin":false},"created_at":"2018-06-20T09:30:31Z","updated_at":"2018-06-20T09:30:31Z","author_association":"NONE","body":"Ah, as long as there's a way of doing it! The whole namespace is quite useful for the way we're structuring our policies."}}
{"actor":{"display_login":"jacobwalkr"}}