aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/generators
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-04-05 14:48:49 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-04-05 14:48:49 -0700
commit01034d3be0d7c8c09b551ac612c4b18f86086dc5 (patch)
tree3d5d590d6459f2f3a9ad0b15f08169babcce428c /railties/lib/rails/generators
parentc037659294555298889a7102c580240804f44d84 (diff)
parent096ee1594d329f53ef47d0aff9bb6eef25a18b96 (diff)
downloadrails-01034d3be0d7c8c09b551ac612c4b18f86086dc5.tar.gz
rails-01034d3be0d7c8c09b551ac612c4b18f86086dc5.tar.bz2
rails-01034d3be0d7c8c09b551ac612c4b18f86086dc5.zip
Merge branch 'master' into railstest
* master: (44 commits) Improve the changelog entry [ci skip] Fix explicit names on multiple file fields Correctly parse bigint defaults in PostgreSQL Move changelog to the top [ci skip] Fix indent and remove extra white spaces Fix scope chaining + STI failing test for #9869 Improve `belongs_to touch: true` timestamp test Sort modules in alphabetical order. Avoid an attempt to fetch old record when id was not present in touch callback Use the correct pk field from the reflected class to find the old record Refactor mail_to to not generate intermediate hashes when adding href Ensure mail_to helper does not modify the given html options hash Use inspect when writing the foreign key from the reflection Use a space after the comment sign when showing the result of commands Exclude template files for rdoc API [ci skip] template should have generic name use | to have more intent revealing code Revert "Merge pull request #10034 from benofsky/fix_skipping_object_callback_filters" stop depending on callbacks ... Conflicts: railties/test/application/rake_test.rb
Diffstat (limited to 'railties/lib/rails/generators')
-rw-r--r--railties/lib/rails/generators/named_base.rb2
-rw-r--r--railties/lib/rails/generators/rails/model/USAGE26
2 files changed, 17 insertions, 11 deletions
diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb
index 8b4f52bb3b..d891ba1215 100644
--- a/railties/lib/rails/generators/named_base.rb
+++ b/railties/lib/rails/generators/named_base.rb
@@ -40,7 +40,7 @@ module Rails
def indent(content, multiplier = 2)
spaces = " " * multiplier
- content = content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
+ content.each_line.map {|line| line.blank? ? line : "#{spaces}#{line}" }.join
end
def wrap_with_namespace(content)
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: