我正在运行命令
rake db:seed
重置数据库后。我收到了错误
User(#70157849141260) expected, got Fixnum(#70157833845020)
当我跑步时
rake db:seed --trace
这是我得到的反馈
** Invoke db:seed (first_time)
** Execute db:seed
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Invoke db:migrate (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:migrate
** Invoke db:_dump (first_time)
** Execute db:_dump
** Invoke db:structure:dump (first_time)
** Invoke environment
** Invoke db:load_config
** Execute db:structure:dump
Nothing annotated.
** Execute db:abort_if_pending_migrations
rake aborted!
User(#70157849141260) expected, got Fixnum(#70157833845020)
这可能是我的问题?
以下是在种子文件中创建用户的代码:
User.create([
{ :email => "brooks.stevena@gmail.com", :username => "admin",
:crypted_password => "$2a$10$zhjpf.6hg5w9DlI68GQsM.qSiQi33BgDaHtrCopV4Zn2nOeA2OnN6", :salt => "pqXxLgsnbB1CZzEcEFwF",
:roles_mask => 1, :last_login_at => "2013-12-22 17:11:57", :last_logout_at => nil,
:last_activity_at => "2013-12-24 15:31:46", :activation_state => "active",
:activation_token => nil, :activation_token_expires_at => nil, :reset_password_token => nil,
:reset_password_token_expires_at => nil, :reset_password_email_sent_at => nil, :remember_me_token => nil,
:remember_me_token_expires_at => nil, :created_at => "2013-12-11 18:08:03", :updated_at => "2013-12-11 18:08:11",
:ip => nil, :location => "1", :latitude => nil, :longitude => nil, :redmine_user => nil }
], :without_protection => true )
答案 0 :(得分:0)
你的括号和括号看起来不正确。我不明白为什么你需要'[]'或'{}'。我建议您将代码更改为:
User.create(:email => "brooks.stevena@gmail.com", :username => "admin",
:crypted_password => "$2a$10$zhjpf.6hg5w9DlI68GQsM.qSiQi33BgDaHtrCopV4Zn2nOeA2OnN6",
:salt => "pqXxLgsnbB1CZzEcEFwF", :roles_mask => 1,
:last_login_at => "2013-12-22 17:11:57", :last_logout_at => nil,
:last_activity_at => "2013-12-24 15:31:46", :activation_state => "active",
:activation_token => nil, :activation_token_expires_at => nil,
:reset_password_token => nil, :reset_password_token_expires_at => nil,
:reset_password_email_sent_at => nil, :remember_me_token => nil,
:remember_me_token_expires_at => nil, :created_at => "2013-12-11 18:08:03",
:updated_at => "2013-12-11 18:08:11", :ip => nil, :location => "1",
:latitude => nil, :longitude => nil, :redmine_user => nil,
:without_protection => true )