Reputation: 6110
I am creating a simple users table and when I ran rake db:migrate it appeared to create_table(:users) Howerver I got the following warnings at the same time. I tried running rake db:migrate again and then I got the 2nd error on this page. How can I check if the table was created, and how to prevent this warning/error?
ERROR1
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method DemoApp::Application#task called at /Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.1/lib/rails/application.rb:214:in `initialize_tasks'
ERROR 2
rake aborted!
undefined local variable or method `d' for main:Object
This is what I get with --trace
/Users/anderskitson/rails_project/demo_app/Rakefile:1:in `<top (required)>'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/rake:19:in `load'
/Users/anderskitson/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/bin/rake:19:in `<main>'
I ran
rails generate scaffold User name:string email:string
Then I ran
rake db:migrate
my rake file looks like
d# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
require 'rake'
DemoApp::Application.load_tasks
Upvotes: 1
Views: 2484
Reputation: 138012
Remove the d
which is the first character in your Rakefile:
d# Add your own tasks in files placed in lib/tasks ending in .rake,
You'll recognise this line because it's the line number which is pointed to in the error message you pasted, and you can tell that that's the erroneous part of the line because it's exactly the letter which the error message told you it couldn't identify.
Upvotes: 4
Reputation: 5403
It depends on the version of Rails that you're currently using, but I'd recommend generating a new Rails application and copying over the generated Rakefile to ensure you're up to date. There's likely a require "rake/rdoctask"
in there that needs to be changed.
That said, this warning likely is not causing the migration failure.
Run it again with --trace
to get the full stack trace.
Upvotes: 0