我有一個before_save
在這樣定義我Message
型號:如何在不執行「before_save」的情況下「update_attributes」?
class Message < ActiveRecord::Base
before_save lambda { foo(publisher); bar }
end
當我這樣做:
my_message.update_attributes(:created_at => ...)
foo
和bar
被執行。
有時,我想更新消息的字段而不執行foo
和bar
。
我怎麼能更新,例如,created_at
字段(在數據庫中)而不執行foo
和bar
?
看起來像一個很好的通用解決方案!一個問題:究竟是什麼'Message.batch = true'呢? –
這只是一面旗幟。你可以用任何你想要的來代替它。 – jbescoyez
我已經用更明確的標誌更新了示例。 – jbescoyez