2012-02-01 138 views
1

我创建一个简单的用户表,当我跑耙db:迁移它似乎create_table(:用户)Howerver我同时得到以下警告。我试着运行rake数据库:再次迁移,然后我得到了第二个错误在这个页面上。如何检查表是否已创建,以及如何防止此警告/错误?耙db:迁移失败

ERROR1

WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead. 
    at /Users/anderskitson/.rvm/gems/[email protected]/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/[email protected]/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 

这就是我与--trace

/Users/anderskitson/rails_project/demo_app/Rakefile:1:in `<top (required)>' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run' 
/Users/anderskitson/.rvm/gems/[email protected]/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>' 
/Users/anderskitson/.rvm/gems/[email protected]/bin/rake:19:in `load' 
/Users/anderskitson/.rvm/gems/[email protected]/bin/rake:19:in `<main>' 

我跑

轨生成脚手架用户名:字符串email:字符串

然后我跑

rake db:migrate 

我耙文件看起来像

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 
+0

你可以添加有问题的迁移到你的问题。 – 2012-02-01 20:46:07

+0

我很抱歉,我不确切地知道您的意思 – 2012-02-01 20:53:03

+0

为您尝试运行的迁移添加代码。 – bensie 2012-02-01 21:02:55

回答

4

取出d这是你的Rakefile的第一个字符:

d# Add your own tasks in files placed in lib/tasks ending in .rake, 

,因为它是它指出,在您粘贴错误消息的行号你会认识到这条线,你可以告诉大家,这是该行的错误部分,因为这正是错误消息告诉你它无法识别的字母。

+0

的输出,修复了我的问题的一半。我的数据库成功创建,但我仍然得到所有的警告消息,为什么会这样。 – 2012-02-02 00:25:00

0

这取决于on Rails的版本你目前使用的,但我建议生成一个新的Rails应用程序,并复制生成的Rakefile,以确保你达到dat即那里可能有require "rake/rdoctask"需要改变。

也就是说,此警告可能不会导致迁移失败。

--trace再次运行以获得完整的堆栈跟踪。

+0

我添加了--trace – 2012-02-01 20:51:48