Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model generator USAGE doc improvement #10092

Merged
merged 1 commit into from Apr 5, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 16 additions & 10 deletions railties/lib/rails/generators/rails/model/USAGE
Expand Up @@ -52,20 +52,26 @@ Available field types:


`rails generate model product supplier:references{polymorphic}` `rails generate model product supplier:references{polymorphic}`


You can also specify some options just after the field type. You can use the For integer, string, text and binary fields an integer in curly braces will
following options: be set as the limit:


limit Set the maximum size of the field giving a number between curly braces `rails generate model user pseudo:string{30}`
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


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: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: Examples:
Expand Down