aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorSammy Larbi <sam@codeodor.com>2012-12-29 11:11:45 -0600
committerSammy Larbi <sam@codeodor.com>2012-12-29 11:11:45 -0600
commit0dad3ed4c630e9337c02d9aa6e3ea2e5cd613211 (patch)
tree67d5c3ffca03e581fd65d23f11ca50556d5c5d49 /guides
parent427544ed45ff8dccc4c94065ce243806189b282e (diff)
downloadrails-0dad3ed4c630e9337c02d9aa6e3ea2e5cd613211.tar.gz
rails-0dad3ed4c630e9337c02d9aa6e3ea2e5cd613211.tar.bz2
rails-0dad3ed4c630e9337c02d9aa6e3ea2e5cd613211.zip
Document JoinTable migration generator
Diffstat (limited to 'guides')
-rw-r--r--guides/source/migrations.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/guides/source/migrations.md b/guides/source/migrations.md
index f2aa72492f..1ce132e02d 100644
--- a/guides/source/migrations.md
+++ b/guides/source/migrations.md
@@ -202,6 +202,25 @@ end
This migration will create a `user_id` column and appropriate index.
+There is also a generator which will produce join tables if `JoinTable` is part of the name:
+
+```bash
+rails g migration CreateJoinTableCustomerProduct customer product
+```
+
+will produce the following migration:
+
+```ruby
+class CreateJoinTableCustomerProduct < ActiveRecord::Migration
+ def change
+ create_join_table :customers, :products do |t|
+ # t.index [:customer_id, :product_id]
+ # t.index [:product_id, :customer_id]
+ end
+ end
+end
+```
+
### Model Generators
The model and scaffold generators will create migrations appropriate for adding