【问题标题】:ruby on rails error rake db:createruby on rails 错误 rake db:create
【发布时间】:2011-05-25 10:26:30
【问题描述】:

我一直在使用 ruby​​ on rails 没问题,现在突然每次我运行 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>

请帮忙???

这是我所有的命令

   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>'

【问题讨论】:

  • 请添加完整的跟踪......
  • 是的,添加完整的跟踪,值得检查/报告它是否发生在您尝试调用的每个 rake 任务中。
  • 我不明白为什么它工作正常没有问题现在我遇到了这些问题,我仍然可以在旧网站上工作而没有问题,它只是新创建的网站,怎么会有什么改变 ruby /rails 自动下载升级?????????
  • 这绝对是 Chris 引用的内容的转贴。几天前我遇到了同样的问题。

标签: ruby-on-rails ruby rake


【解决方案1】:

这会对你有所帮助。

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

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,在 git hub 上找到了 Jim Weirich 的帖子解决了我的问题

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

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

    第二个问题(上面的 mjansen401 和 r00k)是新版本的 rake 不再将其 DSL 命令(task、file、desc、import 等)放在 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
    

    如果这些对你有用,请告诉我。

    希望对你有帮助

    【讨论】:

      猜你喜欢
      • 2013-02-13
      • 2012-09-30
      • 2011-04-29
      • 1970-01-01
      • 2018-07-09
      • 1970-01-01
      • 2013-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多