views:

28

answers:

1

I have a lot of model observers, so I want to organize them in a subdirectory under the model folder.

model --> observer --> user_observer.rb, activity_observer.rb, etc.

Prior to placing in the subdirectory, I was loading the observers like this:

Rails::Initializer.run do |config|
   config.active_record.observers = :user_observer, :activity_observer
end

Now when I try to launch the server, I get the following error:

`load_missing_constant': Expected /Users/cscairns/source/myapp/app/models/observer/user_observer.rb to define UserObserver (LoadError)

What is the proper syntax that I need to use in environment.rb now that the observers look like?

Observer::UserObserver < ActiveRecord::Observer
A: 

Looks like answer can be found here: http://handyrailstips.com/tips/4-loading-observers-automatically-from-their-own-folder.

keruilin