{"action":"created","issue":{"url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/158","labels_url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/158/labels{/name}","comments_url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/158/comments","events_url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/158/events","html_url":"https://github.com/bbatsov/rails-style-guide/pull/158","id":111792959,"number":158,"title":"Added enum macro recommendation","user":{"login":"Epigene","id":2983624,"avatar_url":"https://avatars.githubusercontent.com/u/2983624?v=3","gravatar_id":"","url":"https://api.github.com/users/Epigene","html_url":"https://github.com/Epigene","followers_url":"https://api.github.com/users/Epigene/followers","following_url":"https://api.github.com/users/Epigene/following{/other_user}","gists_url":"https://api.github.com/users/Epigene/gists{/gist_id}","starred_url":"https://api.github.com/users/Epigene/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Epigene/subscriptions","organizations_url":"https://api.github.com/users/Epigene/orgs","repos_url":"https://api.github.com/users/Epigene/repos","events_url":"https://api.github.com/users/Epigene/events{/privacy}","received_events_url":"https://api.github.com/users/Epigene/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-10-16T09:15:52Z","updated_at":"2015-10-16T15:09:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bbatsov/rails-style-guide/pulls/158","html_url":"https://github.com/bbatsov/rails-style-guide/pull/158","diff_url":"https://github.com/bbatsov/rails-style-guide/pull/158.diff","patch_url":"https://github.com/bbatsov/rails-style-guide/pull/158.patch"},"body":"Enums are a meaningful addition to Rails model ecosystem and can be used in the majority of models where a field can take a limited selection of values, but bool is insufficient.\r\n\r\nPlacing their definition under attr macros is one way to go about it, another might be to put them above attr macros, right under constants.\r\nI'd be glad to hear others' opinion on the matter."},"comment":{"url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/comments/148742122","html_url":"https://github.com/bbatsov/rails-style-guide/pull/158#issuecomment-148742122","issue_url":"https://api.github.com/repos/bbatsov/rails-style-guide/issues/158","id":148742122,"user":{"login":"KevinBongart","id":154600,"avatar_url":"https://avatars.githubusercontent.com/u/154600?v=3","gravatar_id":"","url":"https://api.github.com/users/KevinBongart","html_url":"https://github.com/KevinBongart","followers_url":"https://api.github.com/users/KevinBongart/followers","following_url":"https://api.github.com/users/KevinBongart/following{/other_user}","gists_url":"https://api.github.com/users/KevinBongart/gists{/gist_id}","starred_url":"https://api.github.com/users/KevinBongart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KevinBongart/subscriptions","organizations_url":"https://api.github.com/users/KevinBongart/orgs","repos_url":"https://api.github.com/users/KevinBongart/repos","events_url":"https://api.github.com/users/KevinBongart/events{/privacy}","received_events_url":"https://api.github.com/users/KevinBongart/received_events","type":"User","site_admin":false},"created_at":"2015-10-16T15:09:28Z","updated_at":"2015-10-16T15:09:28Z","body":"I believe the hash syntax, while useful for customizing, brings a risk of breaking changes if the developers were to tweak the values (here, 0 and 1, but can get much bigger in some apps).\r\n\r\nThe alternative is simpler, straightforward, hides the configuration, but allows to be changed for customization if needed:\r\n\r\n```ruby\r\nenum gender: [:female, :male]\r\n```"}}