NoMethodError: undefined method `last_comment' after upgrading to rake 11

Solution 1:

Rake 11.0.1 removes the last_comment method which Rails 2.3 rspec-core (< 3.4.4) uses. Therefore until/if a patch is released we need to pin rake to an older version in Gemfile:

gem 'rake', '< 11.0'

then:

$ bundle update
$ grep rake Gemfile.lock 
      rake
      rake (>= 0.8.7)
    rake (10.5.0)
      rake
  rake (< 11.0)

We are now using rake 10.5.0 which still has the last_comment method and our rake tasks will work again.

UPDATE: This has now been fixed in rspec, so the only thing necessary should be updating rspec.

Solution 2:

in Rails quick fix can be edit ./Rakefile (in your app folder)

and add these lines before calling Rails.application.load_tasks:

module TempFixForRakeLastComment
  def last_comment
    last_description
  end 
end
Rake::Application.send :include, TempFixForRakeLastComment

so entire Rakefile might look like

  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