Ruby on rails 更新属性/更新属性跳过回调

Ruby on rails 更新属性/更新属性跳过回调,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,我想在保存后用数组更新字段 同时,还有其他不同的后保存,忽略此项 我尝试使用update\u列,但它并没有序列化数组,所以我需要让它使用update\u属性或update\u属性 How can I update array to a single field without performing callbacks 如果您想跳过回调和验证,那么它的伴奏就是要使用的方法。从类别范围来看,有。 或者,您可以使用JSON(而不是序列化数组),如: 至少,当您处理序列化时,您可能会感兴趣。这真是太棒

我想在保存后用数组更新字段

同时,还有其他不同的后保存,忽略此项

我尝试使用update\u列,但它并没有序列化数组,所以我需要让它使用update\u属性或update\u属性

How can I update array to a single field without performing callbacks
如果您想跳过回调和验证,那么它的伴奏就是要使用的方法。从类别范围来看,有。
或者,您可以使用JSON(而不是序列化数组),如:


至少,当您处理序列化时,您可能会感兴趣。

这真是太棒了。我查阅了ruby文档,找不到解决方案。这真的很有帮助。非常感谢@tobagoA guy给出的答案,我说这不是我要找的。他只是投了我所有的问题!!!
class Bar < ActiveRecord::Base
  def foo= array
    write_attribute :foo, array.to_json
  end

  def foo
    JSON.parse(read_attribute :foo)
  end
end
Bar.first.update_column :foo, [1,2,3].to_json