This project is archived and is in readonly mode.
Dirty tracking doesn't catch in-place changes to field values
-
Jeremy Kemper
- State changed from new to invalid
- Assigned user set to Jeremy Kemper
This is intentional and well-documented.
The dirty plugin froze attributes, treating the database values as immutable. This is a big change, though, so when I merged with Rails I kept attributes mutable and introduced user.login_will_change! instead.
I plan to make attributes frozen in Rails 2.2, though. In 2.1 I'll catch common mutators, typically on strings, and give a deprecation warning to give plenty of heads-up time before making the change.
-
fhwang
Is there one single place where this functionality -- as it exists now in Rails 2.1, and plans for the future -- is being documented? A pointer would be appreciated.
And perhaps this is already answered there, but: Is it possible to turn off dirty tracking for one model, or for all of them? I can appreciate the functionality that comes with model dirtying but I would also hope that the design of ActiveRecord can accommodate those who think that the tradeoffs aren't worth it for them.
-
Jeremy Kemper
There is no tradeoff. Simply do not use the tracking methods if you do not wish to. You can turn off partial updates, which use dirty tracking, with ActiveRecord::Base.partial_updates = false. It's a global switch.
This feature and its ramifications are documented in ActiveRecord::Dirty.