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.
精彩评论