{"action":"created","issue":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/920","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/920/labels{/name}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/920/comments","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/920/events","html_url":"https://github.com/rails-api/active_model_serializers/pull/920","id":78457088,"number":920,"title":"Allow :key to be specified for attributes overridden in the serializer","user":{"login":"navinpeiris","id":410939,"avatar_url":"https://avatars.githubusercontent.com/u/410939?v=3","gravatar_id":"","url":"https://api.github.com/users/navinpeiris","html_url":"https://github.com/navinpeiris","followers_url":"https://api.github.com/users/navinpeiris/followers","following_url":"https://api.github.com/users/navinpeiris/following{/other_user}","gists_url":"https://api.github.com/users/navinpeiris/gists{/gist_id}","starred_url":"https://api.github.com/users/navinpeiris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/navinpeiris/subscriptions","organizations_url":"https://api.github.com/users/navinpeiris/orgs","repos_url":"https://api.github.com/users/navinpeiris/repos","events_url":"https://api.github.com/users/navinpeiris/events{/privacy}","received_events_url":"https://api.github.com/users/navinpeiris/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/0.10.x","name":"0.10.x","color":"bfd4f2"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/Needs%20Code%20Review","name":"Needs Code Review","color":"fbca04"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/Needs%20Team%20Discussion","name":"Needs Team Discussion","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-20T09:53:21Z","updated_at":"2015-05-21T06:04:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/pulls/920","html_url":"https://github.com/rails-api/active_model_serializers/pull/920","diff_url":"https://github.com/rails-api/active_model_serializers/pull/920.diff","patch_url":"https://github.com/rails-api/active_model_serializers/pull/920.patch"},"body":"This makes the following example code function as expected:\r\n\r\n```ruby\r\nclass BlogSerializer < ActiveModel::Serializer\r\n  attribute :num_article, key: :articlesCount\r\n\r\n  def num_articles\r\n    object.articles.count\r\n  end\r\nend\r\n```\r\n\r\nAn alternative to the above is to specify the attribute and corresponding method as `articlesCount`, but this allows us to follow ruby code conventions while allowing us to customize the response as expected by the client."},"comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments/104149363","html_url":"https://github.com/rails-api/active_model_serializers/pull/920#issuecomment-104149363","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/920","id":104149363,"user":{"login":"navinpeiris","id":410939,"avatar_url":"https://avatars.githubusercontent.com/u/410939?v=3","gravatar_id":"","url":"https://api.github.com/users/navinpeiris","html_url":"https://github.com/navinpeiris","followers_url":"https://api.github.com/users/navinpeiris/followers","following_url":"https://api.github.com/users/navinpeiris/following{/other_user}","gists_url":"https://api.github.com/users/navinpeiris/gists{/gist_id}","starred_url":"https://api.github.com/users/navinpeiris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/navinpeiris/subscriptions","organizations_url":"https://api.github.com/users/navinpeiris/orgs","repos_url":"https://api.github.com/users/navinpeiris/repos","events_url":"https://api.github.com/users/navinpeiris/events{/privacy}","received_events_url":"https://api.github.com/users/navinpeiris/received_events","type":"User","site_admin":false},"created_at":"2015-05-21T06:04:16Z","updated_at":"2015-05-21T06:04:16Z","body":"Cool, thanks again @joaomdmoura. Again, this is a nicety and doesn't hold us back, so please feel free to close this if you'd rather keep it as is"}}