Stereonaut!

Archive for the ‘activerecord’ tag

lib/active_record/base.rb:2808:in `attributes_with_quotes': undefined method `each' for true:TrueClass (NoMethodError)

with one comment

OK, hopefully this might help someone some time somewhere. If you are getting the error on the title, it's mainly because you are using a changed method on your ActiveRecord model.

I was working with an ActiveRecord model that handles an string with quotes, so when trying to save the model, that exception was raised. The problem is that ActiveRecord uses a changed method internally for all attributes that were modified. When you are using a changed method yourself, you are overwriting it, hence the error. In my case:

/opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2808:in `attributes_with_quotes': undefined method `each' for true:TrueClass (NoMethodError)
from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/base.rb:2706:in `update_without_lock'

Solution, just get rid of your changed method and rename it something else.

Also helpful information, here.

Written by David Moreno

February 9th, 2009 at 8:49 pm

Categorized in: in-english,ruby

Tagged with , ,