Re: [Rails] Why is the behaviour of ActiveRecord method_missing different between rails 3.2 and 4.0 ?

13 views
Skip to first unread message

Frederick Cheung

unread,
Aug 30, 2013, 7:47:17 AM8/30/13
to rubyonra...@googlegroups.com
On Thu, Aug 29, 2013 at 2:29 PM, starfry <goo...@jelmail.com> wrote:
I have been working on updating a rails application to 4.0 and spent some time getting to the bottom of why it wasn't working.

What I found was, if a model has a method_missing definition then it is called instead of any accessors. This causes any model set-up to fail.


As far as I am aware, the accessors for attributes have always been generated using method_missing (the method missing hook then actually defines the accessors, so after that method missing is not used).

What might possibly have changed is when this gets triggered. Regardless if you do override method_missing it's a good idea to call to the superclass as other aspects of active record may rely on this.

Fred

Reply all
Reply to author
Forward
0 new messages