{"action":"created","issue":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1658","repository_url":"https://api.github.com/repos/rails-api/active_model_serializers","labels_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1658/labels{/name}","comments_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1658/comments","events_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1658/events","html_url":"https://github.com/rails-api/active_model_serializers/issues/1658","id":145660554,"number":1658,"title":"Inherited methods are nil","user":{"login":"pareeohnos","id":1657075,"avatar_url":"https://avatars.githubusercontent.com/u/1657075?v=3","gravatar_id":"","url":"https://api.github.com/users/pareeohnos","html_url":"https://github.com/pareeohnos","followers_url":"https://api.github.com/users/pareeohnos/followers","following_url":"https://api.github.com/users/pareeohnos/following{/other_user}","gists_url":"https://api.github.com/users/pareeohnos/gists{/gist_id}","starred_url":"https://api.github.com/users/pareeohnos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pareeohnos/subscriptions","organizations_url":"https://api.github.com/users/pareeohnos/orgs","repos_url":"https://api.github.com/users/pareeohnos/repos","events_url":"https://api.github.com/users/pareeohnos/events{/privacy}","received_events_url":"https://api.github.com/users/pareeohnos/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/rails-api/active_model_serializers/labels/V:%200.10.x","name":"V: 0.10.x","color":"bfd4f2"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-04T11:43:17Z","updated_at":"2016-04-04T18:15:54Z","closed_at":"2016-04-04T18:15:54Z","body":"#### Expected behavior vs actual behavior\r\nI've created an `ApplicationSerializer` which I want to contain the property `success` which is in all child serializers. My understanding is that by declaring the attribute within the superclass, all child classes will inherit this. I am finding that this is partially true when the attribute declared is a method, rather than a property on the underlying resource.\r\n\r\nWhen I render using an instance of the child serializer, the attribute key is present, however the value is always null. If I override the attribute method and simply call `super` within it, I get the value I expect, however this defeats the purpose of inheritance.\r\n\r\n\r\n#### Steps to reproduce\r\nI have the following structure\r\n\r\n```ruby\r\nclass ApplicationSerializer < ActiveModel::Serializer\r\n  attributes :status\r\n\r\n  def status\r\n    object.try(:errors).blank? && object.try(:error).blank?\r\n  end\r\n\r\nend\r\n```\r\n\r\n```ruby\r\nclass ErrorResponse < ActiveModelSerializers::Model\r\n  attr_accessor :error\r\nend\r\n```\r\n\r\n```ruby\r\nclass ErrorResponseSerializer < ApplicationSerializer\r\n  attributes :error\r\nend\r\n```\r\n\r\nIn my controller, I am rendering the response using:\r\n\r\n```ruby\r\nrender json: ErrorResponse.new('Error message here'), status: :unauthorized\r\n```\r\n\r\nI am expecting to get the JSON response of\r\n\r\n```json\r\n{\r\n    \"success\": false,\r\n    \"error\": \"Error message here\"\r\n}\r\n```\r\n\r\nHowever, I instead get the response\r\n\r\n```json\r\n{\r\n    \"success\": null,\r\n    \"error\": \"Error message here\"\r\n}\r\n```\r\n\r\nTo remedy this, I can change the definition of the `ErrorResponseSerializer` class to the following:\r\n\r\n```ruby\r\nclass ErrorResponseSerializer < ApplicationSerializer\r\n  attributes :error\r\n\r\n  def success\r\n    super\r\n  end\r\nend\r\n```\r\n\r\nAnd this then works as expected.\r\n\r\n#### Environment\r\n\r\nActiveModelSerializers Version: 0.10.0.rc4 d30aa4c \r\nOutput of `ruby -e \"puts RUBY_DESCRIPTION\"`: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]\r\nOS Type & Version: Mac OS X 10.11.3\r\nIntegrated application and version: Rails 4.2.1"},"comment":{"url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/comments/205428489","html_url":"https://github.com/rails-api/active_model_serializers/issues/1658#issuecomment-205428489","issue_url":"https://api.github.com/repos/rails-api/active_model_serializers/issues/1658","id":205428489,"user":{"login":"NullVoxPopuli","id":199018,"avatar_url":"https://avatars.githubusercontent.com/u/199018?v=3","gravatar_id":"","url":"https://api.github.com/users/NullVoxPopuli","html_url":"https://github.com/NullVoxPopuli","followers_url":"https://api.github.com/users/NullVoxPopuli/followers","following_url":"https://api.github.com/users/NullVoxPopuli/following{/other_user}","gists_url":"https://api.github.com/users/NullVoxPopuli/gists{/gist_id}","starred_url":"https://api.github.com/users/NullVoxPopuli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NullVoxPopuli/subscriptions","organizations_url":"https://api.github.com/users/NullVoxPopuli/orgs","repos_url":"https://api.github.com/users/NullVoxPopuli/repos","events_url":"https://api.github.com/users/NullVoxPopuli/events{/privacy}","received_events_url":"https://api.github.com/users/NullVoxPopuli/received_events","type":"User","site_admin":false},"created_at":"2016-04-04T18:15:54Z","updated_at":"2016-04-04T18:15:54Z","body":"Closing for now, please re-open if this issue still exists"}}