【发布时间】:2012-02-06 21:33:27
【问题描述】:
我想让 after_update 回调仅在某个配置参数为 true 时执行。 起初我有这样的事情:
after_update :do_something
...
def do_something
return unless MyApp::Application.config.some_config
actualy_do_something
end
但后来我想,为什么不让回调赋值有条件呢? 像这样:
after_update :do_something if MyApp::Application.config.some_config
但是我不完全理解我在这里做什么。这会在什么时候改变?仅在服务器重新启动时?如何测试这种行为?我不能只设置配置,模型文件不会被再次读取。
请指教。
【问题讨论】:
标签: ruby-on-rails activerecord configuration callback