Created
July 28, 2012 17:36
-
-
Save anga/3194130 to your computer and use it in GitHub Desktop.
Load all observers (Ruby on Rails)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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