A legacy database has a column changed
(containing an updated_at timestamp).
This results in an error changed? is defined by ActiveRecord, but only when I open its association.
I have tried to:
开发者_运维技巧- override instance_method_already_implemented?
- And to alias that column.
- To add custom methods using
write_attribute
andread_attribute
.
But none of that avoids the failure.
Can a changed
column exist? At all? I would prefer not to have to alter the table, because that means changing a lot of legacycode too.
One of the few downsides to ActiveRecord are all the already-taken attribute names. This is one of them, and it can be an error-prone nightmare to work around ActiveRecord's declarations.
If your database supports them, you could create a view of the table just to present different column names to ActiveRecord.
Try disabling partial updates in ActiveRecord in your initializer:
ActiveRecord::Base.partial_updates = false
精彩评论