Copied most of the info from ticket #5074 observer bug. The
problem I encounter is the same as in that ticket, except I don't
have issues with rails console (that has already been resolved in
ticket #5074 observer bug), but with running rake tasks. Attached
patch resolves this issue for rake tasks as well.
Versions used
I am using Ruby 1.8.7 and Rails 3.0.5
Steps to reproduce
1) rails new foo
2) cd foo
3) rails generate model bar
4) rails generate observer bar
5) rake db:migrate
6) in config/application.rb file:
config.active_record.observers = :bar_observer
6) touch lib/tasks/qux.rake
7) in lib/tasks/qux.rake:
desc "Qux"
task :qux => :environment do
Bar
end
8) rake qux
Results in an error:
Expected /Users/ludo/src/foo/app/models/bar.rb to define Bar