@@ -6,6 +6,11 @@ Description:
6
6
model's attributes. Timestamps are added by default, so you don't have to
7
7
specify them by hand as 'created_at:datetime updated_at:datetime'.
8
8
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
+
9
14
You don't have to think up every attribute up front, but it helps to
10
15
sketch out a few so you can start working with the model immediately.
11
16
@@ -27,7 +32,8 @@ Available field types:
27
32
`rails generate model post title:string body:text`
28
33
29
34
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:
31
37
32
38
integer
33
39
primary_key
@@ -73,6 +79,10 @@ Available field types:
73
79
`rails generate model user username:string{30}:uniq`
74
80
`rails generate model product supplier:references{polymorphic}:index`
75
81
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`
76
86
77
87
Examples:
78
88
`rails generate model account`
0 commit comments