Rails3のエラー「undefined method `task'」
Rails3で
% rake db:create
を実行すると、下のようなエラーが出た。
エラー内容
rake aborted! undefined method `task' for #<Blog::Application:0x000000018869d0> (See full trace by running task with --trace)
解決方法
調べてみるとどうやらrake0.9.0のバグのせいらしい。
そこで、Rakefileに以下の行を加えることで解決。
- Rakefile(編集前)
require File.expand_path('../config/application', __FILE__) require 'rake' Blog::Application.load_tasks
- Rakefile(編集後)
require File.expand_path('../config/application', __FILE__) require 'rake' module ::Blog class Application include Rake::DSL end end module ::RakeFileUtils extend Rake::FileUtilsExt end Blog::Application.load_tasks