after_create有多种方法?

Joe*_*nas 26 ruby-on-rails ruby-on-rails-3 rails-activerecord

我试图在创建之后调用两个方法,但是将它们放入数组中是行不通的...我在rails docs或google中找不到任何东西......有经验的人?

after_create [:do_this, :do_that]
Run Code Online (Sandbox Code Playgroud)

不起作用

atm*_*ish 75

无需在数组中包围方法.只需使用:

after_create :do_this, :and_then_this

奖励信息:如果before_*回调返回false,则取消所有后续回调和相关操作.如果after_*回调返回false,则取消所有后续回调.回调通常按照定义的顺序运行,但回调定义为模型上的方法(最后调用).