3

I decided to go through the tutorial. After I create a new app and add new user:string email:string and then perform rake db:migrate in the app directory, I get this output:

rake aborted! 
undefined method `task' for #<DemoApp::Application:0x00000100e49e08>
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks'
/usr/local/rvm/gems/ruby-1.9.2-p180@rails3tutorial/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing'
/Users/zigloo99/rails_projects/demo_app/Rakefile:7:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:78:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:61:in `block in run'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/lib/rake/application.rb:59:in `run'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/gems/rake-0.9.0/bin/rake:31:in `<top (required)>'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin/rake:19:in `load'
/usr/local/rvm/gems/ruby-1.9.2-p180@global/bin/rake:19:in `<main>'

I am using RVM too ruby 1.9.2 and rails 3.0.7 as in the tutorial. Any thoughts?

zigloo99
  • 134
  • 1
  • 10
  • [demo_app]$ gem query *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.7) actionpack (3.0.7) activemodel (3.0.7) activerecord (3.0.7) activeresource (3.0.7) activesupport (3.0.7) arel (2.0.10) builder (2.1.2) bundler (1.0.13) erubis (2.6.6) i18n (0.5.0) mail (2.2.19) mime-types (1.16) polyglot (0.3.1) rack (1.2.2) rack-mount (0.6.14) rack-test (0.5.7) rails (3.0.7) railties (3.0.7) rake (0.9.0) sqlite3-ruby (1.3.2) thor (0.14.6) treetop (1.4.9) tzinfo (0.3.27) – zigloo99 May 23 '11 at 00:02
  • possible duplicate of [Undefined method 'task' using rake 0.9.0.beta.4](http://stackoverflow.com/questions/5287121/undefined-method-task-using-rake-0-9-0-beta-4) – sawa May 23 '11 at 00:05

2 Answers2

10

This is happening because the latest version of Rake (0.9.0) is broken on Rails 3.0 applications and we are currently awaiting a solid fix.

Right now, a way around this error is to add this line above the load_tasks line in your application's Rakefile:

<AppName>::Application.send :include, ::Rake::DSL if defined?(::Rake::DSL)
dgrumm
  • 3
  • 2
Ryan Bigg
  • 106,965
  • 23
  • 235
  • 261
3

Another solution is to require rake 0.8.7 in your Gemfile before starting a new rails project.

# Gemfile
gem 'rake', '0.8.7', :require => 'rake'

then run bundle install

thomasfedb
  • 5,990
  • 2
  • 37
  • 65