How can I make an aggregated property support ActiveRecord::Dirty semantics?
- by Eric
I have an aggregated attribute which I want to be able ask about its _changed? ness, etc.
composed_of :range,
:class_name => 'Range',
:mapping => [ %w(range_begin begin), %w(range_end end)],
:allow_nil => true
If I use the aggregation:
foo.range = 1..10
This is what I get:
foo.range # => 1..10
foo.range_changed? # NoMethodError
foo.range_was # ditto
foo.changed # ['range_begin', 'range_end']
So basically, I'm not getting ActiveRecord::Dirty semanitcs on aggregated attributes. Is there any way to do that? I'm not having a lot of luck with alias_attribute_with_dirty, etc.