0

运行 rake db:migrate 时出现错误。我最近在这之后添加了一个 gem gcm_on_rails,只是我得到了错误。

 rake aborted!
 Don't know how to build task 'rails_env'

 Tasks: TOP => db:migrate => db:load_config

请帮忙

   rake aborted!
   Don't know how to build task 'rails_env'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task_manager.rb:49:in `[]'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:60:in `lookup_prerequisite'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `block in prerequisite_tasks'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `collect'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:56:in `prerequisite_tasks'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
  /Users/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
  /Users/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
  /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
   /Users/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:in `load'
   /Users/test/.rvm/gems/ruby-1.9.2-p320@global/bin/rake:19:in `<main>'
   Tasks: TOP => db:migrate => db:load_config
4

1 回答 1

0

为了使用 gem 中指定的 rake 任务,我在我的应用程序控制器中添加了以下代码。这导致了这个问题。当我删除它时,它工作正常。

require 'rake'
Rake::Task.clear
MyAPP::Application.load_tasks
于 2012-10-16T06:19:16.287 回答