是按顺序声明的rails执行的before_save回调

时间:2016-02-16 10:33:23

标签: ruby-on-rails-4 activerecord

无法确认这一点。 'before_save'回调是按照它们的写入顺序执行的吗?

e.g。

before_save :first, :second

def first
  #some code
end

def second
  #some code
end

first之前始终会调用second吗?有人可以请一个是或否答案?

我已经阅读了rails文档,特别是取消了回调,但它没有用yes / no直接回答这个问题。

干杯

1 个答案:

答案 0 :(得分:2)

是的,回调按照定义的顺序执行。

   after_create :do_this, :and_then_this

可能重复 Enforce an Order to Rails Callbacks

相关问题