最近突然发现执行 rake 时遇到问题
$ rake -T
rake aborted!
undefined method `task' for #<Demo::Application:0x2b3a0934>
(See full trace by running task with --trace)
上网看了一下是 rake 的 bug ,参考这里
看E文可能比较累,这里简单列出解决办法:
修改 rails 项目的 Rakefile 文件,在 require 'rake' 之后加入下面一段:
class Rails::Application
include Rake::DSL if defined?(Rake::DSL)
end
另外,如果用了项目模板,可以这么加入:
# monkey patch: rake 0.9.0 bugfix
gsub_file 'Rakefile', /require\ 'rake'/, %Q[require 'rake'
class Rails::Application
include Rake::DSL if defined?(Rake::DSL)
end]
open class 就是好!