How to fixed the ” undefined method ‘task’ ” in Rails 3.0.7
rake aborted! undefined method `task' for #<Yourapp::Application:0x00000101759a70> (See full trace by running task with --trace)
Does this look familiar? I know what your thinking. WDF? I didn’t do anything. Right? Well, actually you did. You updated bundler, which used rake 0.9.0 and your broke it all! Abandon ship! Abandon ship! Oh wait.. there is a fix. And here it is. Open your Rakefile. Got it open? Good. Now put this snippet of code inbetween the
require 'rake'
And the
Yourapp::Application.load_tasks
The snippet
module ::Yourapp
class Application
include Rake::DSL end
end
module ::RakeFileUtils
extend Rake::FileUtilsExt
end
And wow! Things should be working. If your having problems after this, just delete your Gemfile.lock, remove all of your gems in your gemset (you are using RVM with gemsets aren’t you?),then bundle install your gems again. Yup, your rake will be working as right as rain in no time.
Also so you know, patches have been merged to the latest version of rails that fixes this problem so if you just upgrade your problem will be solved, however.. it might break more things ;)
2 Notes/ Hide
-
thenetduck posted this