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 recently updated to the latest version (2.0.0), and in our app we use this gem on some POROs. Here's an example of how we use it:
class PatientForm
include ActiveModel::Model
include ActiveModel::Attributes
include ActiveModel::Validations::Callbacks
strip_attributes only: :last_name, collapse_spaces: true
...
end
After the update, the callback to collapse_spaces seemed to break with this error:
undefined method '[]=' for an instance of PatientForm
I was able to fix it by manually just defining the [] and []= methods on the model
class PatientForm
include ActiveModel::Model
include ActiveModel::Attributes
include ActiveModel::Validations::Callbacks
strip_attributes only: :last_name, collapse_spaces: true
def [](key)
send(key)
end
def []=(key, value)
send("#{key}=", value)
end
...
end
Is this an actual bug in the release, or are the callbacks not intended to be used with objects that don't get persisted to the database like this and we should use the gem directly instead?
The text was updated successfully, but these errors were encountered:
@rmm5t Sorry, yes, this was working prior to v2.0.0. We have a workaround for this, so its not a huge issue, I just wanted to bring it to your attention. Thanks for the quick response!
I recently updated to the latest version (2.0.0), and in our app we use this gem on some POROs. Here's an example of how we use it:
After the update, the callback to
collapse_spaces
seemed to break with this error:undefined method '[]=' for an instance of PatientForm
I was able to fix it by manually just defining the
[]
and[]=
methods on the modelIs this an actual bug in the release, or are the callbacks not intended to be used with objects that don't get persisted to the database like this and we should use the gem directly instead?
The text was updated successfully, but these errors were encountered: