(使用 Rails 3.1 的 RoR,gem rake 0.9.2.2)
我正在尝试运行最基本的自定义 rake 任务,如您在此处看到的:
task :update_me => :environment do
Product.all.each do |product|
puts product.link
end
end
我不断收到以下错误。如果我只是打印出 hello world 并取出 ":environment" 部分,该任务就会运行。我的 rake 任务似乎在其中的 ":environment" 部分遇到了问题,但我需要它来访问我的模型。
rake aborted!
missing :controller
Tasks: TOP => update_me => environment
(See full trace by running task with --trace)
痕迹:
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:179:in `default_controller_and_action'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:76:in `normalize_options!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:59:in `initialize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1302:in `new'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1302:in `add_route'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1282:in `decomposed_match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `block in match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:1268:in `match'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:505:in `map_method'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/mapper.rb:467:in `get'
/home/ubuntu/code/preevio/config/routes.rb:35:in `block in <top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:282:in `eval_block'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:260:in `draw'
/home/ubuntu/code/preevio/config/routes.rb:1:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `block in load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:40:in `load_paths'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:16:in `reload!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:26:in `block in updater'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/file_update_checker.rb:78:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:27:in `updater'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
/home/ubuntu/code/preevio/config/environment.rb:5:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application.rb:103:in `require_environment!'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/railties-3.2.3/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/home/ubuntu/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/bin/rake:19:in `load'
/home/ubuntu/.rvm/gems/ruby-1.9.2-p290@rails31/bin/rake:19:in `<main>'