我正在运行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)
这是我的seed.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。我没有改变最新的提交。
答案 0 :(得分:0)
出于某种原因,当我从Github repo重新克隆并重新启动我的服务器并rake db:reset。有效。 Rails众神?对不起,老实说,我不知道它为什么开始工作。