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

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

Add Comment


  • 3 Answer(s)

      Rake 11.0.1 removes the last_comment method  Rails 2.3 rspec-core (< 3.4.4) uses. There are patch  released 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)
    

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

    Answered on January 11, 2019.
    Add Comment

    Rails quick fix  edit ./Rakefile in  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
    

    Entire 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
    

    Answered on January 11, 2019.
    Add Comment

    Using Rspec gem doesrun the command:

    bundle update rspec-rails
    

    Answered on January 11, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.