BUG: v1.0.1 changes the behavior of active model
Closed this issue · 1 comments
swishstache commented
Tell us about your environment
Ruby Version:
3.0.4
Rails Version:
6.1.5.1
PostgreSQL Version:
12
Store Attribute Version:
1.0.1
What did you do?
Our rails app includes classes that aren't ActiveRecord classes. An example is below.
class TestObject
include ActiveModel::Model
include ActiveModel::Validations
include ActiveModel::Dirty
define_attribute_methods :content
attr_reader :content
def content=(value)
@content = value
content_will_change!
end
def reset_dirty_tracking
changes_applied
end
end
What did you expect to happen?
The behavior of class should not be changed by store_attribute.
What actually happened?
The following error occurs.
Minitest::UnexpectedError: NoMethodError: undefined method `[]' for # lib/rails_ext/active_record_mutation_tracker_extention.rb:8:in `change_to_attribute'
It appears "StoreAttribute::MutationTracker#change_to_attribute" expects the "attributes" to be an instance of "ActiveModel::LazyAttributeSet"
when it (in this case) is an instance of the class – TestObject
.
palkan commented
Released in 1.0.2