开发者

ActiveRecord::Observer file placement

Where is the best place to keep Observer files in my rails project?

The following code will have an observer for both the account class and the share class right?

class AuditObserver < ActiveRecord::Observer
  observe :account
  observe :share

  def after_update(account)
    AuditTrail.new(account, "UPDAT开发者_如何转开发ED")
  end
end


According to http://api.rubyonrails.org/classes/ActiveRecord/Observer.html - observers should be placed in the app/models directory.

Also I forgot to add config.active_record.observers = :comment_observer, :signup_observer to my application.rb file - just a heads up on a gotcha.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜