提交 31d37826 编写于 作者: N noinkling

Additional clarification on password:digest in scaffold and model generator help [ci skip]

上级 2a7fcc8c
......@@ -6,6 +6,11 @@ Description:
model's attributes. Timestamps are added by default, so you don't have to
specify them by hand as 'created_at:datetime updated_at:datetime'.
As a special case, specifying 'password:digest' will generate a
password_digest field of string type, and configure your generated model and
tests for use with ActiveModel has_secure_password (assuming the default ORM
and test framework are being used).
You don't have to think up every attribute up front, but it helps to
sketch out a few so you can start working with the model immediately.
......@@ -27,7 +32,8 @@ Available field types:
`rails generate model post title:string body:text`
will generate a title column with a varchar type and a body column with a text
type. You can use the following types:
type. If no type is specified the string type will be used by default.
You can use the following types:
integer
primary_key
......@@ -73,6 +79,10 @@ Available field types:
`rails generate model user username:string{30}:uniq`
`rails generate model product supplier:references{polymorphic}:index`
If you require a `password_digest` string column for use with
has_secure_password, you should specify `password:digest`:
`rails generate model user password:digest`
Examples:
`rails generate model account`
......
......@@ -14,9 +14,10 @@ Description:
unique index. "index" could also be given instead of "uniq" if one desires
a non unique index.
As a special case, passing 'password:digest' will generate a password_digest
field and configure your generated model, controller, views, and test suite
for use with ActiveModel has_secure_password.
As a special case, specifying 'password:digest' will generate a
password_digest field of string type, and configure your generated model,
controller, views, and test suite for use with ActiveModel
has_secure_password (assuming they are using Rails defaults).
Timestamps are added by default, so you don't have to specify them by hand
as 'created_at:datetime updated_at:datetime'.
......@@ -37,3 +38,4 @@ Examples:
`rails generate scaffold post`
`rails generate scaffold post title body:text published:boolean`
`rails generate scaffold purchase amount:decimal tracking_id:integer:uniq`
`rails generate scaffold user email:uniq password:digest`
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册