我是Ruby on Rails的新手,并创建了一个新的环境和我的第一次迁移。迁移看起来像这样:
=============================================== ==========================
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string "first_name", :limit => 25
t.string "last_name", :limit => 50
t.string "email", :default =>"", :null =>false
t.string "password", :limit => 40
t.timestamps
end
end
def down
drop_table :users
end
end
=============================================== ========================
我保存它并尝试使用跟踪运行rake,我收到以下错误。
=============================================== ========================
$ rake db:migrate --trace
rake aborted!
NameError: undefined local variable or method `rake' for main:Object
/home/ubuntu/workspace/Rakefile:1:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/rake_module.rb:28:in `load_rakefile'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake- 10.4.2/lib/rake/application.rb:689:in `raw_load_rakefile'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:94:in `block in load_rakefile'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:93:in `load_rakefile'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:77:in `block in run'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:176:in `standard_exception_handling'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/lib/rake/application.rb:75:in `run'
/usr/local/rvm/gems/ruby-2.1.5@rails4/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/usr/local/rvm/gems/ruby-2.1.5@rails4/bin/rake:23:in `load'
/usr/local/rvm/gems/ruby-2.1.5@rails4/bin/rake:23:in `<main>'
我用Google搜索并搜索了堆栈溢出并且没有更明智。
感谢您的帮助。
答案 0 :(得分:1)
已解决:我创建了一个新环境并比较了Rakefile,发现我无意中添加了一个&#34; RAKE&#34;在我删除的文件的顶部。一切都解决了。 -