0

我正在运行 rake db:seed 并收到此错误:

-- create_table("users", {:force=>true})
   -> 0.0097s
-- add_index("users", ["email"], {:name=>"index_users_on_email", :unique=>true})
   -> 0.0009s
-- add_index("users", ["reset_password_token"], {:name=>"index_users_on_reset_password_token", :unique=>true})
   -> 0.0008s
-- initialize_schema_migrations_table()
   -> 0.0029s
DEFAULT USERS
rake aborted!
can't dup NilClass
/Users/shrav/mvhomefront/db/seeds.rb:9:in `dup'
/Users/shrav/mvhomefront/db/seeds.rb:9:in `<top (required)>'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `block in load'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in `load_dependency'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in `load'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/railties-4.0.0/lib/rails/engine.rb:540:in `load_seed'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/tasks/database_tasks.rb:153:in `load_seed'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:181:in `block (2 levels) in <top (required)>'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/gems/activerecord-4.0.0/lib/active_record/railties/databases.rake:140:in `block (2 levels) in <top (required)>'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `eval'
/Users/shrav/.rvm/gems/ruby-2.0.0-p247/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:setup => db:seed
(See full trace by running task with --trace)

这是我的种子.rb

# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#   cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
#   Mayor.create(name: 'Emanuel', city: cities.first)
puts 'DEFAULT USERS'
user = User.find_or_create_by_email :name => ENV['ADMIN_NAME'].dup, :email => ENV['ADMIN_EMAIL'].dup, :password => ENV['ADMIN_PASSWORD'].dup, :password_confirmation => ENV['ADMIN_PASSWORD'].dup
puts 'user: ' << user.name

我不知道出了什么问题,因为这应该有效。让我知道我还需要发布什么。我的存储库位于 github.com/shravmehta/mvhomefront。我没有更改最新提交的任何内容。

4

1 回答 1

0

出于某种原因,当我从 Github repo 重新克隆并重新启动服务器并 rake db:reset 时。有效。铁路之神?抱歉,我真的不知道它为什么开始工作。

于 2013-10-09T01:52:13.043 回答