0

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:

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.

Community
  • 1
  • 1
berkes
  • 26,996
  • 27
  • 115
  • 206

2 Answers2

1

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.

dunedain289
  • 2,348
  • 18
  • 21
  • My database (MySQL) supports this and it sounds a good idea, since it solves some other problems I had too. Thanks for the pointer. – berkes Mar 16 '11 at 10:13
0

Try disabling partial updates in ActiveRecord in your initializer:

ActiveRecord::Base.partial_updates = false
edmz
  • 3,350
  • 2
  • 22
  • 29
  • 1
    I think that disables dirty checking but it will still have defined the changed method. – edmz Mar 15 '11 at 22:35
  • Nope :(. I tried this, but it still fails. For the record: I am using it in a rake task, so I tried both an initializer and to set this at the start of the rake task. But the error stays. – berkes Mar 15 '11 at 22:37