[英]Password digest can't be blank
Ruby on Rails 3.2 Ruby on Rails 3.2
My form is creating a new distributor. 我的表格正在创建一个新的经销商。 I have added the
gem 'bcrypt-ruby', '3.0.1'
, my database table has password_digest: string
and my model has :password, :password_confirmation,
and has_secure_password
. 我添加了
gem 'bcrypt-ruby', '3.0.1'
,我的数据库表有password_digest: string
,我的模型有:password, :password_confirmation,
和has_secure_password
。
When I submit my form the error I get is Password digest can't be blank
. 当我提交表单时,我得到的错误是
Password digest can't be blank
。
This is what is POSTed: 这是POST的内容:
Started POST "/distributors" for x.x.x.x at 2014-03-14 12:59:07 -0700
Processing by DistributorsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"x=", "distributor"=>{"company_name"=>"First Account", "company_website
"=>"First.com", "contact_name"=>"First", "contact_email"=>"first@moon.com", "contact_title"=>"owner", "company_phone"=>"555-665-5555", "company_region"=>"Asia Paci
fic", "company_address"=>"172 E Center Street", "company_country"=>"Cambodia", "company_city"=>"Covina", "company_state"=>"Not Applicable", "company_zip"=>"01970",
"sales_contact_name"=>"Bob", "sales_contact_email"=>"bobby@moon.com", "tech_contact_name"=>"Steph", "tech_contact_email"=>"steph@moon.com", "additional_name"=>"",
"additional_email"=>"", "additional_name2"=>"", "additional_email2"=>"", "area_served"=>["", "Bangladesh"], "terms_and_conditions"=>"1"}, "commit"=>"Register"}
Distributor Load (0.1ms) SELECT `distributors`.* FROM `distributors` WHERE `distributors`.`contact_email` = 'first@moon.com' LIMIT 1
(0.1ms) BEGIN
Distributor Exists (0.2ms) SELECT 1 AS one FROM `distributors` WHERE `distributors`.`contact_email` = 'first@moon.com' LIMIT 1
(0.1ms) ROLLBACK
Does someone know what I'm missing? 有人知道我错过了什么吗? Thank you
谢谢
Your log is missing both the password and password_confirmation fields being set. 您的日志缺少正在设置的密码和password_confirmation字段。 It should look more like this
看起来应该更像这样
{"utf8"=>"✓", "authenticity_token"=>"dsdfhjdskhfsdfhjsdfhjsdfhjdsfhjsdfE=", "user"=>{"email"=>"email@provider.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Register"}
The hash you post to your distributors
route does not contain any information about a password. 您发布到
distributors
路线的哈希不包含任何有关密码的信息。 It is not possible to create a distributor without a password, with the code you have written. 使用您编写的代码无法创建没有密码的经销商。 So the error message is perfectly correct.
所以错误信息是完全正确的。
You need to add a password
and a password_confirmation
field to your webpage. 您需要在网页中添加
password
和password_confirmation
字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.