-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inherited methods are nil #1658
Comments
@pareeohnos hey, can you try this commit: 5be33af |
hmm that's strange @NullVoxPopuli that's worked. Something after this commit must be breaking something though. I have just installed from master before trying this, and that commit appears to have been added to master 3 days ago? |
I have no idea, I'm confused about this, too. |
Should be fixed by #1661 |
…hods Fixes rails-api#1653, rails-api#1658, rails-api#1660 Define "scope_name" on instance singleton, not all instances
Closing for now, please re-open if this issue still exists |
Seems to be working for me. Cheers guys :) |
Expected behavior vs actual behavior
I've created an
ApplicationSerializer
which I want to contain the propertysuccess
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.When 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.Steps to reproduce
I have the following structure
In my controller, I am rendering the response using:
I am expecting to get the JSON response of
However, I instead get the response
To remedy this, I can change the definition of the
ErrorResponseSerializer
class to the following:And this then works as expected.
Environment
ActiveModelSerializers Version: 0.10.0.rc4 d30aa4c
Output of
ruby -e "puts RUBY_DESCRIPTION"
: ruby 2.1.3p242 (2014-09-19 revision 47630) [x86_64-darwin13.0]OS Type & Version: Mac OS X 10.11.3
Integrated application and version: Rails 4.2.1
The text was updated successfully, but these errors were encountered: