ruby on rails - update_attibute/update_attributes skip callbacks -
i want update field array in after_save.
there different other after_saves performing meanwhile, ignore this.
i tried using update_column, not serialize array, need work update_attribute or update_attributes.
how can update array single field without performing callbacks
activerecord::persistence#update_column(name, value) , companion activerecord::persistence#update_columns(attributes) methods use if want skip callbacks , validations. class scope there activerecord::relation#update_all(updates).
alternatively go json (instead of serializing array) like:
class bar < activerecord::base def foo= array write_attribute :foo, array.to_json end def foo json.parse(read_attribute :foo) end end and somewhere else:
bar.first.update_column :foo, [1,2,3].to_json at least, when deal serializing activerecord::store interesting you.
Comments
Post a Comment