ruby on rails错误rake db:create

时间:2011-05-25 10:26:31

标签: ruby-on-rails ruby rake

我一直在rails上使用ruby没问题,现在突然每次我运行rake db:create我得到以下错误:

C:\>cd xampp

C:\xampp>cd htdocs

C:\xampp\htdocs>cd what

C:\xampp\htdocs\what>rake db:create
rake aborted!
undefined method `task' for #<What::Application:0x20eb1e0>

(See full trace by running task with --trace)

C:\xampp\htdocs\what>

请帮忙???

这是我的所有cmd

   C:\xampp\htdocs\comeon>rake db:create --trace
rake aborted!
undefined method `task' for #<Comeon::Application:0x211fb30>
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:215:
in `initialize_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:139:
in `load_tasks'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application.rb:77:i
n `method_missing'
C:/xampp/htdocs/comeon/Rakefile:7:in `<top (required)>'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:495:in `r
aw_load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:78:in `bl
ock in load_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:77:in `lo
ad_rakefile'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:61:in `bl
ock in run'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:129:in `s
tandard_exception_handling'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/lib/rake/application.rb:59:in `ru
n'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'

C:/Ruby192/bin/rake:19:in `load'
C:/Ruby192/bin/rake:19:in `<main>'

2 个答案:

答案 0 :(得分:5)

这会对你有帮助。

gem uninstall rake

gem install rake -v 0.8.7

如果问题仍然存在,请卸载rake并使用

进行安装
gem uninstall rake
gem install rake

了解更多信息

  

Undefined method 'task' using Rake 0.9.0

答案 1 :(得分:1)

我遇到了同样的问题,发现Jim Weirich在git hub中发布的帖子解决了我的问题

https://github.com/jimweirich/rake/issues/33#issuecomment-1213705

  

这里有两个问题:(1)dimitko的问题是内置rake命令与新gem的库文件混合在一起。安排你的$ PATH环境列表,以便rake的gem版本优先于内置版本应该解决这个问题。如果您使用的是bundler,您可能还想尝试'捆绑exec rake'。

     

第二个问题(上面的mjansen401和r00k)是rake的新版本不再将其DSL命令(任务,文件,desc,导入等)放在Object命名空间的根目录中(将它们放在Object中意味着每个对象都有一个任务命令,不是很好。通过将Rake :: DSL模块混合到需要命令的任何模块中,可以使用DSL命令。

     

在更新rails以使用Rake 0.9.x之前,在调用Application.load_tasks之前将以下内容放在项目Rakefile中:

class Rails::Application
  include Rake::DSL if defined?(Rake::DSL)
end
  

让我知道这些是否适合您。

希望有所帮助

相关问题