Kri*_*ris 127 rake ruby-on-rails ruby-on-rails-3
当rake我运行任何任务时,我得到:
NoMethodError:未定义的方法`last_comment'for
之后bundle update推出了新版本的rake版本11.0.1.
$ grep rake Gemfile.lock
rake
rake (>= 0.8.7)
rake (11.0.1)
rake
$ bundle update
$ bundle exec rake db:drop # any rake task
Run Code Online (Sandbox Code Playgroud)
NoMethodError:#Rake :: Application:0x007ff0cf37be38>未定义的方法`last_comment'
版本
Kri*_*ris 152
Rake 11.0.1 删除了该last_comment方法Rails 2.3rspec-core(<3.4.4)使用.因此,如果/如果发布了补丁,我们需要将rake引脚到Gemfile中的旧版本:
gem 'rake', '< 11.0'
Run Code Online (Sandbox Code Playgroud)
然后:
$ bundle update
$ grep rake Gemfile.lock
rake
rake (>= 0.8.7)
rake (10.5.0)
rake
rake (< 11.0)
Run Code Online (Sandbox Code Playgroud)
我们现在使用rake 10.5.0仍然有last_comment方法,我们的rake任务将再次工作.
更新:现在已经在rspec中修复了,所以唯一需要的是更新rspec.
equ*_*nt8 72
在Rails快速修复中可以编辑./Rakefile(在你的app文件夹中)
并在调用之前添加这些行Rails.application.load_tasks:
module TempFixForRakeLastComment
def last_comment
last_description
end
end
Rake::Application.send :include, TempFixForRakeLastComment
Run Code Online (Sandbox Code Playgroud)
整个Rakefile可能看起来像
require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'resque/tasks'
+ # temp fix for NoMethodError: undefined method `last_comment'
+ # remove when fixed in Rake 11.x
+ module TempFixForRakeLastComment
+ def last_comment
+ last_description
+ end
+ end
+ Rake::Application.send :include, TempFixForRakeLastComment
+ ### end of temfix
+
task "resque:preload" => :environment
Rails.application.load_tasks
Run Code Online (Sandbox Code Playgroud)
Gal*_*cha 27
更新到最新的Rspec宝石做的工作:
bundle update rspec-rails
小智 21
只需升级宝石 rspec-rails
现在: gem 'rspec-rails', '~> 3.5', '>= 3.5.2'
拥抱!
yek*_*kta 20
这是rake中已经解决的问题.
@ equivalent8的答案是一个猴子补丁,应该避免.
正如@Kris指出的那样,这是一个孤立的问题rake 11.0.1.由于@Kris已经发布了他的答案,因此可以使用Rake的新版本,理想情况下,您可以与时俱进,而不是固定在旧版本的rake上.相信我,我一直在那里,如果你可以帮助它,这不是一个好主意.这也不是Rails 2.3或任何版本的rails的问题.
任何耙子< v11.0.1或> v11.0.1 and < v12将工作,但这仍然是一个解决方案,也应该避免; 理想情况下,你将能够与时俱进.
由于last_comment被弃用,因此应该升级依赖项本身.在我的情况下,rspec-core它偶然只在v3.4.4中解决了这个问题.
修复
将依赖项升级到不调用last_comment但调用的版本last_description.它可能rspec并升级rspec-core到3.4.4或更高将解决它. rspec-core<3.4.4电话last_comment.
如果您的依赖项没有不调用的版本,请last_description成为一个好公民并提交PR来修复它:)
| 归档时间: |
|
| 查看次数: |
37232 次 |
| 最近记录: |