Skip to content
Browse files

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
  • Loading branch information...
1 parent 363c08f commit 11c1a5a1f85971c8e46defd614ea80c979de6bb8 @smathy smathy committed Apr 4, 2013
Showing with 16 additions and 10 deletions.
  1. +16 −10 railties/lib/rails/generators/rails/model/USAGE
View
26 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}`
@ka8725
ka8725 added a note Oct 25, 2013

this generator doesn't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
+ 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:

0 comments on commit 11c1a5a

Please sign in to comment.
Something went wrong with that request. Please try again.