Skip to content
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

Is the documentation for serializing POROs wrong? #1996

Closed
jholton opened this issue Dec 7, 2016 · 3 comments
Closed

Is the documentation for serializing POROs wrong? #1996

jholton opened this issue Dec 7, 2016 · 3 comments

Comments

@jholton
Copy link

jholton commented Dec 7, 2016

The docs say to use the attributes method:
https://github.com/rails-api/active_model_serializers/blob/master/docs/howto/serialize_poro.md

# my_model.rb
class MyModel < ActiveModelSerializers::Model
  attributes :id, :name, :level
end

However, using version 0.10.3 in my project, when I try this I get an error:
undefined method 'attributes' for MyModel:Class (NoMethodError)

Using attr_accessor, as the previous documentation describes, works for me:
https://github.com/rails-api/active_model_serializers/blob/05618eac3d1b793cca8c2337090d00102f44f442/docs/howto/serialize_poro.md

# my_model.rb
class MyModel < ActiveModelSerializers::Model
  attr_accessor :id, :name, :level
end

Does the current documentation describe behavior not available in 0.10.3?
Or is the documentation wrong?

Thanks.

@zaccari
Copy link

zaccari commented Dec 8, 2016

I ran into the same issue - the documentation on GitHub reflects the master branch, which contains the changes in this pull request that adds support for the attributes method, but haven't been pushed as a new gem version (0.10.4 I believe). To fix for now I just updated my Gemfile to use the git repo:

gem 'active_model_serializers', git: 'git://github.com/rails-api/active_model_serializers.git', branch: 'master', require: true

@jholton
Copy link
Author

jholton commented Dec 11, 2016

Ah, I see. Thanks.

@jholton jholton closed this as completed Dec 11, 2016
@bf4
Copy link
Member

bf4 commented Dec 11, 2016

@jholton @mzaccari Thanks for the issue and helping each other out! I have a little more work to do before the next release. Let me know how things are going. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants