Question

I'm pretty new to programming so need some help in interpreting an error.

I am trying to create an local variable in my console of ProjectUpdate Model. I also have a Project Model and I think that is why its raising an error. It is worried about calling the method update on project so it seems to me I'll have to rename ProjectUpdate model to something that doesn't conflict with the updates method on project is this the correct interpretation or what else could be happening?

Here is my console:

irb(main):003:0> projectupdate1 = ProjectUpdate.new
ActiveRecord::DangerousAttributeError: update is defined by Active Record
Was it helpful?

Solution

The update column will be the problem.

Rails generates accessor methods for each of your attributes. If an attribute has the same name as a method provided by activerecord (such as update then the accessor would hide the original method. In times past this would lead to mysterious problems when activerecord tried to call its method but called your accessor instead, these days it detects this automatically.

You would normally create a migration to rename the offending column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top