Ruby on Rails ActiveRecord::DangerousAttributeError

Posted on 17 August 2009

If you get a Rails exception ActiveRecord::DangerousAttributeError then you'll find it's because one of your attributes is using a name reserved by Active Record. Particularly when the attribute has the name of one of Active Record instance methods.

For me I was using owner_id as a custom foreign key. A quick change to owned_by_id and all was fixed.

About Paul

Paul works for Kyan web design agency in Surrey, UK as a Ruby on Rails developer.

Follow Paul on Twitter

Email: paulsturgess [at] gmail.com

Read more articles in the archive →

Comments...

  • What version of rails?
    I'm using 2.1.0 on one of my apps and when I used connection_id as a model attribute, I got no such error and had to spend hours figuring it out.

    austin_web_developer at 27 Aug 09 at 03:02

Got something to say?