Hello All,

Currently, `serialized` columns get save to the database whether they are 
changed or not. [Github][1]. Since the serialized columns can be modified 
inline, `Dirty` is not used. This behavior introduces too much database 
overhead for us, so I'd like to patch that code right out of there.

## Having trouble extending ActiveRecord

`ActiveRecord::Base.ancestors` returns `ActiveRecord::Core` before 
`ActiveRecord::AttributeMethods::Dirty`, so the methods in `Core` take 
precedence over those in `Dirty`.

I was thinking `Dirty` overrides the behavior of `Core` and should have 
higher precedence. This would allow `@changed_attribtues` to move from 
`Core` to `Dirty`.

Is there history to this decision? Or is it even possible to change this? 
(I mean from both technically, as well as logistically changing something 
so core to the code.)

## Changing the way `Dirty` is implemented.

I played around with storing the original values for an attribute, rather 
than just the values that have been changed. [Github][2] Only 
cloning/storing `@original_values` on attribute access keeps the code as 
close to the current `@changed_attributes` implementation. It not only 
works with serialized variables, but code like 
`model.field.gsub!('a','b')`, without requiring `field_will_change!`

It was more of a whim, but I wanted to know what people thought.

## A more practical solution

I did a more traditional suggestion for a fix. [Github][3] But something in 
me is starting to like changing the way `Dirty` works, even thought it 
seems a bit much.



Any direction would be appreciated.

Thanks for all the hard work on rails,
kbrock

[1]: https://github.com/rails/rails/issues/8328
[2]: https://github.com/rails/rails/pull/13606
[3]: https://github.com/rails/rails/pull/13428

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to