Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Database with hash column in rails

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?

like image 317
Nicos Karalis Avatar asked Mar 28 '26 19:03

Nicos Karalis


1 Answers

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

like image 124
doesterr Avatar answered Mar 31 '26 03:03

doesterr