3

I am migrating an App from PHP to Rails and I have a table with a column called frozen.

Rails i throwing an error:

ActiveRecord::DangerousAttributeError: frozen? is defined by Active Record. Check to make sure that you don't have an attribute or method with the same name.

Is there a way to go around this? I can not rename the column in my table right now.

Also i tried some of the solutions in Stackoverflow and none of those work in rails 4.

Leon
  • 1,262
  • 3
  • 20
  • 41
  • Possible duplicate of [ActiveRecord::DangerousAttributeError](http://stackoverflow.com/questions/7718651/activerecorddangerousattributeerror) – infused Feb 09 '16 at 18:42
  • 1
    I actually tried that before submitting and it does not work in Rails 4. – Leon Feb 09 '16 at 18:46

1 Answers1

4

I solved it by using this code inside the model

def self.instance_method_already_implemented?(method_name)
  return true if method_name == 'frozen'
  return true if method_name == 'frozen?'
  super
end
Leon
  • 1,262
  • 3
  • 20
  • 41