search for: update_attributes_with_sql

Displaying 1 result from an estimated 1 matches for "update_attributes_with_sql".

2007 Jul 12
0
update_all for an AR instance
...on. Are there any built in AR functions that allow you to update a particular object using straight sql UPDATE without saving all the attributes (ie, updating only the attributes you designate.) In any case, I extended ActiveRecord::Base to do something like this. Here is my function: def update_attributes_with_sql(attributes) # allows you to update individual columns without saving the whole record (also much faster) update_sql = if attributes.is_a?(Hash) attributes.to_a.collect do |key_value| k, v = key_value v = v.to_s(:db) if v.is_a?(Time)...