Skip to content

Instantly share code, notes, and snippets.

@anga
Created July 28, 2012 17:36
Show Gist options
  • Save anga/3194130 to your computer and use it in GitHub Desktop.
Save anga/3194130 to your computer and use it in GitHub Desktop.
Load all observers (Ruby on Rails)
# config/application.rb
module RailsApp
class Application < Rails::Application
# ...
files = File.join(Rails.root, 'app', 'models') + File::SEPARATOR + '*_observer.rb'
observers = []
Dir[files].each do |file|
observers << File.basename(file).gsub('.rb','').to_sym
end
config.active_record.observers = observers
# ...
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment