Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Model generator USAGE doc improvement #10092

Merged
merged 1 commit into from

4 participants

@smathy

This started with me noticing that the default option mentioned in the help docs for rails g model didn't actually work. I removed that, and improved the docs for the other options:

  • Added information about syntax for precision/scale of decimals
  • Removed incorrect information about being able to set default
  • Added more examples of usage
railties/lib/rails/generators/rails/model/USAGE
((25 lines not shown))
- `rails generate model user pseudo:string{30}`
`rails generate model user pseudo:string:uniq`

It'd be good to have a :index option here too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
railties/lib/rails/generators/rails/model/USAGE
((16 lines not shown))
- 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}`
+
+ Then can add a `:uniq` or `:index` suffix for unique or standard indexes

Then at the beginning of this sentence seems confusing.

@steveklabnik Collaborator

Yeah, if it was "Then you can" it'd work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@carlosantoniodasilva

Looks good, just minor comments. Thanks.

@smathy

Yeah, sorry, I read that as "Then you can" 10 times. I have those fixes ready, should I just push a second commit? Or you guys want them squashed into a single commit? I don't remember the preference.

@smathy

I went ahead and pushed a new commit, let me know if you want it squashed instead.

@carlosantoniodasilva
@steveklabnik
Collaborator

I do the same thing all the time: I recently submitted some docs to Rust that had THREE ROUNDS of typos.

@smathy smathy 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
11c1a5a
@smathy

Done, thanks.

@carlosantoniodasilva carlosantoniodasilva merged commit 9e4c25e into rails:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 4, 2013
  1. @smathy

    Model generator USAGE doc improved

    smathy authored
     * Added information about syntax for precision/scale of decimals
     * Removed incorrect information about being able to set `default`
     * Added more examples of usage
This page is out of date. Refresh to see the latest.
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}`
+
+ 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:
Something went wrong with that request. Please try again.