0
votes

I'm reading the rails tutorial book and in chapter 6 page 199 I have to make a rake db:migrate, but I get this error:

rake aborted! undefined method `prerequisites' for nil:NilClass

(See full trace by running task with --trace)

When I try with rake db:migrate --trace I get the following errors:

rake aborted!
undefined method `prerequisites' for nil:NilClass
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rspec-rails-2.0.1/lib/rspec/rails/tasks/rspec.rake:3:in `<top (required)>'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rspec-rails-2.0.1/lib/rspec-rails.rb:10:in `load'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rspec-rails-2.0.1/lib/rspec-rails.rb:10:in `block in <class:Railtie>'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie.rb:183:in `call'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie.rb:183:in `block in load_tasks'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie.rb:183:in `each'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie.rb:183:in `load_tasks'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/engine.rb:396:in `block in load_tasks'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/railties.rb:8:in `each'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application/railties.rb:8:in `all'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/engine.rb:396:in `load_tasks'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/application.rb:103:in `load_tasks'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/jeanosorio/ror/sample_app/Rakefile:7:in `<top (required)>'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:495:in `raw_load_rakefile'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:78:in `block in load_rakefile'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:77:in `load_rakefile'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:61:in `block in run'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:129:in `standard_exception_handling'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/application.rb:59:in `run'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/bin/rake:32:in `<top (required)>'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/jeanosorio/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'

I tried update my gems, but I still get the last error. Can anybody help me to solve this issues please.

1
what is in your Rakefile on line 7?fl00r
this is my rakefile on line 7SampleApp::Application.load_tasksJean

1 Answers

0
votes

Hey I had this exact same problem and I believe it is due to the Rails 3.1 changes that the book does not cover. I got it to work by changing my GEMFILE to this:

source 'http://rubygems.org'

gem 'rails', '3.1.0'

gem 'gravatar_image_tag', '1.0.0.pre2'
gem 'will_paginate', '3.0.pre2'
gem 'sqlite3', '1.3.4'

# Asset template engines
gem 'sass-rails', "~> 3.1.0.rc"
gem 'coffee-script'
gem 'uglifier'

gem 'jquery-rails'

group :development do
  gem 'rspec-rails', '2.6.1'
  gem 'annotate', '2.4.0'
  gem 'faker', '0.3.1'
end
group :test do
  gem 'rspec-rails', '2.6.1'
  gem 'webrat', '0.7.1'
  gem 'spork', '0.9.0.rc5'
  gem 'factory_girl_rails', '1.0'
end

Copy and paste that over your current GEMFILE. Next run this command in your terminal

bundle install

Now you are good to go!