我有一个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