Skip to content

Instantly share code, notes, and snippets.

@jsmestad
Created September 26, 2010 07:37
Show Gist options
  • Save jsmestad/597695 to your computer and use it in GitHub Desktop.
Save jsmestad/597695 to your computer and use it in GitHub Desktop.
class Account < ActiveRecord::Base
end
class AccountObserver < ActiveRecord::Observer
def before_create
return true
end
end
module Warehouse
class Application < Rails::Application
# ...
# If you comment out the line, the rake task works.
config.active_record.observers = :account_observer
# ...
end
end
rake myapp:all_accounts --trace
(in /Users/justinsmestad/Documents/myapp)
** Invoke myapp:all_accounts (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute myapp:all_accounts
rake aborted!
Expected /Users/justinsmestad/Documents/myapp/app/models/account.rb to define Account
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:492:in `load_missing_constant'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rspec-core-2.0.0.beta.22/lib/rspec/core/backward_compatibility.rb:20:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rspec-expectations-2.0.0.beta.22/lib/rspec/expectations/backward_compatibility.rb:6:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/inflector/methods.rb:113:in `constantize'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/inflector/methods.rb:112:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/inflector/methods.rb:112:in `constantize'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/core_ext/string/inflections.rb:43:in `constantize'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:182:in `observed_class'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:175:in `observed_classes'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:195:in `observed_classes'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:191:in `initialize'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.0/lib/active_record/observer.rb:96:in `initialize'
/Users/justinsmestad/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/singleton.rb:94:in `new'
/Users/justinsmestad/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/singleton.rb:94:in `instance'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:66:in `instantiate_observer'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:39:in `instantiate_observers'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:39:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.0/lib/active_model/observing.rb:39:in `instantiate_observers'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.0/lib/active_record/railtie.rb:83
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:43:in `run_load_hooks'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:42:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activerecord-3.0.0/lib/active_record/base.rb:1867
/Users/justinsmestad/Documents/myapp/app/models/account.rb:1
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:454:in `load'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:454:in `load_file'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in `new_constants_in'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:453:in `load_file'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:340:in `require_or_load'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:491:in `load_missing_constant'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:183:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:181:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rspec-core-2.0.0.beta.22/lib/rspec/core/backward_compatibility.rb:20:in `const_missing'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rspec-expectations-2.0.0.beta.22/lib/rspec/expectations/backward_compatibility.rb:6:in `const_missing'
/Users/justinsmestad/Documents/myapp/lib/tasks/myapp.rake:29
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `call'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:631:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
/Users/justinsmestad/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/monitor.rb:242:in `synchronize'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/gems/rake-0.8.7/bin/rake:31
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/bin/rake:19:in `load'
/Users/justinsmestad/.rvm/gems/ruby-1.8.7-p302/bin/rake:19
namespace :myapp do
desc "something that does stuff"
task :all_accounts => :environment do
@accounts = Account.all
p "#{@accounts.size} total accounts"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment