Override [] and []= on an ActiveRecord


#1

Okay, I finally figured out what was going on with my mysterious
migrate-to-Rails2 problem.

In Rails 1.x, I got away with over-riding [] and []= on an
ActiveRecord::Base model class. This made for some very convenient
coding, which is now littered all over my application.

In Rails2, you apparently can’t do this.

Should I assume this is right, rather than a bug? Should it be
documented anywhere?

Still trying to think through the best least painful way to refactor my
code.


#2

On 10 Nov 2008, at 22:22, Jonathan R. wrote:

Should I assume this is right, rather than a bug? Should it be
documented anywhere?

[]and []= have (as far as I can remember) allowed you to access
attributes (and are documented as such). Overriding public AR methods
is always going to be risky as you may not be the only using them -
Active Record itself may well be using them.

Still trying to think through the best least painful way to refactor
my
code.
What was your definition of []/[]= ?

Fred