Skip to content

Commit 48cd7d3

Browse files
committed
Merge pull request rails#16285 from noinkling/password_digest_docs
Add password:digest information to scaffold generator help text
2 parents 6d87b78 + 31d3782 commit 48cd7d3

File tree

2 files changed

+18
-2
lines changed
  • railties/lib/rails/generators/rails

2 files changed

+18
-2
lines changed

railties/lib/rails/generators/rails/model/USAGE

+11-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ Description:
66
model's attributes. Timestamps are added by default, so you don't have to
77
specify them by hand as 'created_at:datetime updated_at:datetime'.
88

9+
As a special case, specifying 'password:digest' will generate a
10+
password_digest field of string type, and configure your generated model and
11+
tests for use with ActiveModel has_secure_password (assuming the default ORM
12+
and test framework are being used).
13+
914
You don't have to think up every attribute up front, but it helps to
1015
sketch out a few so you can start working with the model immediately.
1116

@@ -27,7 +32,8 @@ Available field types:
2732
`rails generate model post title:string body:text`
2833

2934
will generate a title column with a varchar type and a body column with a text
30-
type. You can use the following types:
35+
type. If no type is specified the string type will be used by default.
36+
You can use the following types:
3137

3238
integer
3339
primary_key
@@ -73,6 +79,10 @@ Available field types:
7379
`rails generate model user username:string{30}:uniq`
7480
`rails generate model product supplier:references{polymorphic}:index`
7581

82+
If you require a `password_digest` string column for use with
83+
has_secure_password, you should specify `password:digest`:
84+
85+
`rails generate model user password:digest`
7686

7787
Examples:
7888
`rails generate model account`

railties/lib/rails/generators/rails/scaffold/USAGE

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ Description:
99

1010
Attributes are field arguments specifying the model's attributes. You can
1111
optionally pass the type and an index to each field. For instance:
12-
"title body:text tracking_id:integer:uniq" will generate a title field of
12+
'title body:text tracking_id:integer:uniq' will generate a title field of
1313
string type, a body with text type and a tracking_id as an integer with an
1414
unique index. "index" could also be given instead of "uniq" if one desires
1515
a non unique index.
1616

17+
As a special case, specifying 'password:digest' will generate a
18+
password_digest field of string type, and configure your generated model,
19+
controller, views, and test suite for use with ActiveModel
20+
has_secure_password (assuming they are using Rails defaults).
21+
1722
Timestamps are added by default, so you don't have to specify them by hand
1823
as 'created_at:datetime updated_at:datetime'.
1924

@@ -33,3 +38,4 @@ Examples:
3338
`rails generate scaffold post`
3439
`rails generate scaffold post title body:text published:boolean`
3540
`rails generate scaffold purchase amount:decimal tracking_id:integer:uniq`
41+
`rails generate scaffold user email:uniq password:digest`

0 commit comments

Comments
 (0)