Please sign in to comment.
Instantiate observers via Railtie, and run load hooks
I spent some time figuring out how to cleanly use the ActiveResource observer support in a Rails app, finding surprisingly little documentation beyond ActiveModel::Observer itself, arriving at the need for this essential boilerplate in an initializer: ActiveResource::Base.observers = # ... ActiveResource::Base.instantiate_observers This change packages it up as neatly as ActiveRecord observers in Rails: # In config/application.rb config.active_resource.observers = [:post_observer, :comment_observer] The Railtie will instantiate observers automatically, and reload them for each request in development just like rails-observers does for ActiveRecord.
- Loading branch information...
Showing with 18 additions and 1 deletion.