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

Relationship to ActiveModel::Atributes #12

Closed
jaredbeck opened this issue Dec 21, 2018 · 3 comments
Closed

Relationship to ActiveModel::Atributes #12

jaredbeck opened this issue Dec 21, 2018 · 3 comments

Comments

@jaredbeck
Copy link

It seems that in 2017 the Attributes API was implemented in ActiveModel.

Should we add something to the readme here explaining when to use this gem, vs. ActiveModel::Atributes?

@Azdaroth
Copy link
Owner

@jaredbeck Yeah, that would definitely be a good idea

@bensheldon
Copy link

I wanted to document here because every few months I remember I have this question and have been a longtime user and copy-paster-into-new-projects of this active_model_attributes gem.

It seems like it's possible to use ActiveModel::Attributes directly. E.g. this works for me without usage of this gem:

class Person 
  include ActiveModel::Model # necessary to initialize with values e.g. `Person.new(name: "Alice")`
  include ActiveModel::Attributes
  
  attribute :name, :string
end

person = Person.new
person.name = 'Alice'
person.name # => Alice

Why (now) would I use this gem, vs. ActiveModel::Attributes?

@Azdaroth
Copy link
Owner

Azdaroth commented Jan 4, 2021

@bensheldon Now there is not much reason to use it actually if you have a proper version of Rails. This API was not available in ActiveModel for some time, but I think since 5.2 it's been part of Rails already.

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