在我的种子文件中,我有以下内容:
puts "Creating Deans User"
user = User.create!(:email => "test@test.com", :password => "test1234", :password_confirmation => "test1234", :name => "Dean Chester", :admin => true)
puts "User created"
但是当我在控制台中检查这个时,我看到以下内容:
[#<User id: 1, email: "test@test.com", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2012-08-06 10:02:22", updated_at: "2012-08-06 10:02:22", admin: true, name: "Dean Chester">]
加密的密码字段是空白的,所以出了什么问题?
答案 0 :(得分:2)
你有:
attr_accessor :password, :password_confirmation, :current_password
你模特中的?如果是这样,请删除它,它将解决您的问题。
答案 1 :(得分:1)
您的`User.rb。
中可能缺少attr_accessible :password, :password_confirmation