3

I have an application in which I use a database that already existed and already has several data that I can not change.

I want to access this data using ActiveRecord, but the problem is that several of these models have a column called hash and ActiveRecord raises the exception:

ActiveRecord::DangerousAttributeError: hash is defined by ActiveRecord

What can I do to not override the hash method and the same time manage to access this column?

Nicos Karalis
  • 3,724
  • 4
  • 33
  • 62
  • 1
    i guess that this answers your question: http://stackoverflow.com/questions/5909501/how-to-override-a-column-in-rails-model – phoet Oct 24 '12 at 15:08
  • Looks like a duplicate of this question - http://stackoverflow.com/questions/1510875/how-can-i-use-activerecord-on-a-database-that-has-a-column-named-valid-dange – Chris Kimpton Aug 31 '14 at 19:18

1 Answers1

2

Have a look at the safe_attributes gem. Looks like it is built for your problem.

doesterr
  • 3,955
  • 19
  • 26