Rails 3 注释不起作用

发布于 2024-11-15 00:24:10 字数 1779 浏览 3 评论 0原文

当我在命令行运行 annotate 时,出现以下错误:

$ annotate
/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks': undefined method `task' for #<MyApp::Application:0x00000102e03b90> (NoMethodError)
    from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
    from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
    from Rakefile:8:in `<top (required)>'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
    from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `load'
    from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `<main>'

这就是我的 Gemfile 的样子:

source 'http://rubygems.org'

gem 'rails'

gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'will_paginate', '3.0.pre2'

gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'mime-types', :require => 'mime/types'

gem 'rails3-generators'

gem 'devise',  '~> 1.1.3'
gem 'devise_invitable', '~> 0.3.4'

gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_authorization.git'

gem 'aasm'
gem 'braintree'

#For voting
gem 'thumbs_up'

# For In-Place-Editing
gem 'best_in_place'

#For slugs for the plans
gem "friendly_id", "~> 3.2"

gem 'aws-s3'

group :development do
    # Server
    gem 'thin'
    gem 'annotate-models', '1.0.4'
    #gem 'rails-erd'
    gem 'annotate'
    gem 'faker', '0.3.1'
    gem 'ruby_parser'
end

顺便说一句,这一切都在我的本地主机上。

When I run annotate at the command-line, I get the following error:

$ annotate
/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks': undefined method `task' for #<MyApp::Application:0x00000102e03b90> (NoMethodError)
    from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
    from /.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
    from Rakefile:8:in `<top (required)>'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/lib/annotate.rb:17:in `load_tasks'
    from /.rvm/gems/ruby-1.9.2-p0/gems/annotate-2.4.0/bin/annotate:66:in `<top (required)>'
    from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `load'
    from /.rvm/gems/ruby-1.9.2-p0/bin/annotate:19:in `<main>'

This is what my Gemfile looks like:

source 'http://rubygems.org'

gem 'rails'

gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'will_paginate', '3.0.pre2'

gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'mime-types', :require => 'mime/types'

gem 'rails3-generators'

gem 'devise',  '~> 1.1.3'
gem 'devise_invitable', '~> 0.3.4'

gem 'declarative_authorization', :git => 'git://github.com/stffn/declarative_authorization.git'

gem 'aasm'
gem 'braintree'

#For voting
gem 'thumbs_up'

# For In-Place-Editing
gem 'best_in_place'

#For slugs for the plans
gem "friendly_id", "~> 3.2"

gem 'aws-s3'

group :development do
    # Server
    gem 'thin'
    gem 'annotate-models', '1.0.4'
    #gem 'rails-erd'
    gem 'annotate'
    gem 'faker', '0.3.1'
    gem 'ruby_parser'
end

This is all on my localhost btw.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光是把杀猪刀 2024-11-22 00:24:10

Marcamillion,它可能会崩溃,因为在某个阶段您安装了 rake 0.9.0,这对很多人来说破坏了很多东西,而没有弃用方法或警告人们。当您运行捆绑更新时,它会安装 rake 0.9.2 来修复此问题。希望这对其他人有帮助。

Marcamillion, it probably broke because at one stage you had rake 0.9.0 installed, which broke a lot of things for a lot of people without deprecating methods or warning people. When you ran bundle update, it would have installed rake 0.9.2 which fixed this. Hope this helps someone else.

撞了怀 2024-11-22 00:24:10

我已经使用 gem 'annotate', ">=2.5.0" 解决了这个问题。

我正在使用 ruby​​ 1.9.2p320 和 Rails 3.2.13。

I've solved this problem using gem 'annotate', ">=2.5.0".

I'm using ruby 1.9.2p320 and Rails 3.2.13.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文