-
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
ActiveModelSerializers::Model is broken or documentation is out of date #2001
Comments
Thanks for the report. Closed by #2000 |
@joelpresence We're not quite ready to release that API. Am working on it. |
@bf4 thanks for responding, but how do I see the correct documentation for 0.10.3 that shows how to use Also, what do you mean by "that API"? Thanks again and take care! |
Oh, https://github.com/rails-api/active_model_serializers/tree/v0.10.3 , I see, thanks! I see that it mentions attr_accessor. |
Ooooh! Thanks 😄 Same problem. I really have to get better at identifying the correct version of documentation for the gems I'm using! |
Expected behavior vs actual behavior
Thanks for your hard work on AMS! :-)
Expected: If I follow the official AMS documentation to create my own serializable resource that inherits from
ActiveModelSerializers::Model
, it should work and not fail with a syntax error.Actual: fails with error:
Steps to reproduce
(e.g., detailed walkthrough, runnable script, example application)
Follow the instructions to create your own serializable resource (quoting instructions):
The method
attributes
does NOT exist on the classActiveModelSerializers::Model
as you can see:We can actually inspect the class itself at
/Users/joel/.rvm/gems/ruby-2.3.3/gems/active_model_serializers-0.10.3/lib/active_model_serializers/model.rb
:No attributes method that I can see.
The only way I could get this to work is as follows:
That works just fine and serializes as expected.
So either the documentation is wrong (and needs to mention attr_accessor) or the code is wrong in
ActiveModelSerializers::Model
(and needs to add the attributes class method) or both?Any ideas how to fix this or if I missed something obvious?
This is on a rails app generated using
rails new my_app --database=postgresql --api
in case that matters.I verified that I can reproduce this repeatedly on a brand new rails app (with active_model_serializers 0.10.3 installed) so this is definitely not a problem with my rails app or my setup: it is perfectly repeatable on a clean new rails app.
Environment
ActiveModelSerializers Version (commit ref if not on tag):
0.10.3
Output of
ruby -e "puts RUBY_DESCRIPTION"
:ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
OS Type & Version:
OS X 10.12.1
Integrated application and version (e.g., Rails, Grape, etc):
rails 5.0.0.1
ruby 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin16]
OS X 10.12.1
Backtrace
(e.g., provide any applicable backtraces from your application)
Additonal helpful information
(e.g., Gemfile.lock, configurations, PR containing a failing test, git bisect results)
The text was updated successfully, but these errors were encountered: