-
-
Notifications
You must be signed in to change notification settings - Fork 60
Open
Description
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?
cfillion and craisp
Metadata
Metadata
Assignees
Labels
No labels