aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorJason King <jk@handle.it>2013-04-04 11:52:14 -0700
committerJason King <jk@handle.it>2013-04-04 12:25:40 -0700
commit11c1a5a1f85971c8e46defd614ea80c979de6bb8 (patch)
tree9299b3b0476a03d65a3276cc5b2bf81480805843 /railties
parent363c08fa6033a53c1fed18288921c98e70484064 (diff)
downloadrails-11c1a5a1f85971c8e46defd614ea80c979de6bb8.tar.gz
rails-11c1a5a1f85971c8e46defd614ea80c979de6bb8.tar.bz2
rails-11c1a5a1f85971c8e46defd614ea80c979de6bb8.zip
Model generator USAGE doc improved
* Added information about syntax for precision/scale of decimals * Removed incorrect information about being able to set `default` * Added more examples of usage
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/generators/rails/model/USAGE26
1 files changed, 16 insertions, 10 deletions
diff --git a/railties/lib/rails/generators/rails/model/USAGE b/railties/lib/rails/generators/rails/model/USAGE
index 6574200fbf..1998a392aa 100644
--- a/railties/lib/rails/generators/rails/model/USAGE
+++ b/railties/lib/rails/generators/rails/model/USAGE
@@ -52,20 +52,26 @@ Available field types:
`rails generate model product supplier:references{polymorphic}`
- You can also specify some options just after the field type. You can use the
- following options:
+ For integer, string, text and binary fields an integer in curly braces will
+ be set as the limit:
- limit Set the maximum size of the field giving a number between curly braces
- default Set a default value for the field
- precision Defines the precision for the decimal fields
- scale Defines the scale for the decimal fields
- uniq Defines the field values as unique
- index Will add an index on the field
+ `rails generate model user pseudo:string{30}`
- Examples:
+ For decimal two integers separated by a comma in curly braces will be used
+ for precision and scale:
+
+ `rails generate model product price:decimal{10,2}`
+
+ You can add a `:uniq` or `:index` suffix for unique or standard indexes
+ respectively:
- `rails generate model user pseudo:string{30}`
`rails generate model user pseudo:string:uniq`
+ `rails generate model user pseudo:string:index`
+
+ You can combine any single curly brace option with the index options:
+
+ `rails generate model user username:string{30}:uniq`
+ `rails generate model product supplier:references{polymorphic}:index`
Examples: