Rails 3.2:观察者 - 我可以调用 after_something 吗?

Rails 3.2: Observers - Can I call after_something?

使用 Rails3.2 Observers,我发现这些非常酷,但我仍然有一个问题。

好的,我们可以 after_create、after_update、after_destroy、...但是我可以 'after_validate' 吗? 'after_name-of-the-method-in-this-controller' 有泛型吗?

例如:

class EvaluationObserver < ActiveRecord::Observer

 def after_create(record)
  Rails.logger.debug "New Evaluation = #{record}"
 end

 def after_validate(record)
  Rails.logger.debug "Validate the record = #{record}
 end

end

假设我的 EvaluationController.rb 中有一个名为 "validate" 的方法,它是否有效?或者我必须做另一件事?

谢谢 ;-)

好的,下面是回复: https://www.mutuallyhuman.com/blog/2009/01/06/using-custom-activerecord-events-callbacks/

其实很简单