{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/18650","labels_url":"https://api.github.com/repos/rails/rails/issues/18650/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/18650/comments","events_url":"https://api.github.com/repos/rails/rails/issues/18650/events","html_url":"https://github.com/rails/rails/pull/18650","id":55246640,"number":18650,"title":"Conditionally permit strong parameters","user":{"login":"brentdax","id":931226,"avatar_url":"https://avatars.githubusercontent.com/u/931226?v=3","gravatar_id":"","url":"https://api.github.com/users/brentdax","html_url":"https://github.com/brentdax","followers_url":"https://api.github.com/users/brentdax/followers","following_url":"https://api.github.com/users/brentdax/following{/other_user}","gists_url":"https://api.github.com/users/brentdax/gists{/gist_id}","starred_url":"https://api.github.com/users/brentdax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brentdax/subscriptions","organizations_url":"https://api.github.com/users/brentdax/orgs","repos_url":"https://api.github.com/users/brentdax/repos","events_url":"https://api.github.com/users/brentdax/events{/privacy}","received_events_url":"https://api.github.com/users/brentdax/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-23T05:30:17Z","updated_at":"2015-01-24T01:04:13Z","closed_at":"2015-01-23T13:16:07Z","pull_request":{"url":"https://api.github.com/repos/rails/rails/pulls/18650","html_url":"https://github.com/rails/rails/pull/18650","diff_url":"https://github.com/rails/rails/pull/18650.diff","patch_url":"https://github.com/rails/rails/pull/18650.patch"},"body":"This pull request allows you to easily handle cases where a parameter should be permitted in some cases, but not others. For example:\r\n\r\n    # Only administrators can change a post's author.\r\n    params.require(:post).permit(:title, :body, author_id: admin?)\r\n\r\nIt does so by modifying the handling of hashes in `ActionController::Parameters#permit`'s parameter list. If a hash key's value is `true`, then the key is included in the permitted parameters as though it had been listed alongside any other scalar keys (`title` and `body` in this example). If the value is `false` or `nil` (to allow for the use of `Object#try`), the entry is ignored, and any parameter with that name will be rejected as usual.\r\n\r\nDocumentation and tests are included; all tests pass."},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/71292329","html_url":"https://github.com/rails/rails/pull/18650#issuecomment-71292329","issue_url":"https://api.github.com/repos/rails/rails/issues/18650","id":71292329,"user":{"login":"brentdax","id":931226,"avatar_url":"https://avatars.githubusercontent.com/u/931226?v=3","gravatar_id":"","url":"https://api.github.com/users/brentdax","html_url":"https://github.com/brentdax","followers_url":"https://api.github.com/users/brentdax/followers","following_url":"https://api.github.com/users/brentdax/following{/other_user}","gists_url":"https://api.github.com/users/brentdax/gists{/gist_id}","starred_url":"https://api.github.com/users/brentdax/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brentdax/subscriptions","organizations_url":"https://api.github.com/users/brentdax/orgs","repos_url":"https://api.github.com/users/brentdax/repos","events_url":"https://api.github.com/users/brentdax/events{/privacy}","received_events_url":"https://api.github.com/users/brentdax/received_events","type":"User","site_admin":false},"created_at":"2015-01-24T01:04:13Z","updated_at":"2015-01-24T01:04:13Z","body":"If you want the feature and just don't like the syntax, here's an alternative proposal:\r\n\r\n    params.permit(:title, :body, author_id?: admin?, ban: [:reason, :status], ban?: admin?)\r\n\r\nThe `?`-ending keys would be the only ones that would accept a boolean; if a non-`?` variant specified a type, it would be that type, otherwise it would be a scalar. This probably does change existing behavior—I don't *think* there's anything currently stopping you from using a URL-encoded question mark in a parameter name—but only for folks doing things that are kind of nutty to begin with.\r\n\r\n(If you just don't want the feature, on the other hand, I doubt this proposal will change your mind. That's okay!)"}}