Save ActiveRecord attribute without type checking

I want to do a "raw" update an attribute on a ActiveRecord model
without Rails doing type checks on the underlying column in my db.

In other words - I want the create/update equivalent of
"attributes_before_type_cast" which I can use when i read the column.

In my particular example I would like to set a DATE column in Mysql to
"1970-00-00" for example. Mysql lets me set this value in a DATE
column. When I try to set this value in Rails, the column gets nulled

Appreciate any help on this

Use SQL, inside your model.

sql = ActiveRecord::Base.connection()
sql.execute("sql statement for whatever you want to do;")

You can wrap this around a particular private function that you write.


Hi Mats,

Not sure I understand your request, but you might be looking for


Vish - that worked fine!

Thanks a lot!