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

后端 未结 5 908
误落风尘
误落风尘 2020-12-13 03:14

When running any rake task I get:

NoMethodError: undefined method `last_comment\' for

This was after

5条回答
  •  感动是毒
    2020-12-13 03:38

    This is an issue in rake that has been addressed already.

    The answer by @equivalent8 is a monkey patch and should be avoided.

    As @Kris points out, this is an issue isolated to rake 11.0.1. Since @Kris has posted his answer there are new versions of Rake available and ideally you would be able to stay with the times and not be pinned to an old version of rake. Believe me, I've been there and its not a good idea if you can help it. Also this is not an issue with Rails 2.3 or any version of rails.

    Any Rake < v11.0.1 or > v11.0.1 and < v12 will work but this is still a work around and should also be avoided; ideally you'll be able to stay with the times.

    Since last_comment is being deprecated the dependency itself should be upgraded. In my case it was rspec-core which incidentally only fixed this in v3.4.4.

    The Fix

    Upgrade your dependency to a version which doesn't call last_comment but calls last_description instead. Its probably rspec and upgrading rspec-core to 3.4.4 or greater will fix it. rspec-core < 3.4.4 calls last_comment.

    If your dependency doesn't have a version which doesn't call last_description, be a good citizen and submit a PR to fix it :)

提交回复
热议问题