You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
classPersonincludeActiveModel::Model# necessary to initialize with values e.g. `Person.new(name: "Alice")`includeActiveModel::Attributesattribute:name,:stringendperson=Person.newperson.name='Alice'person.name# => Alice
Why (now) would I use this gem, vs. ActiveModel::Attributes?
@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.
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
?The text was updated successfully, but these errors were encountered: