Skip to content

Commit

Permalink
Document JoinTable migration generator
Browse files Browse the repository at this point in the history
  • Loading branch information
codeodor committed Dec 29, 2012
1 parent 427544e commit 0dad3ed
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions guides/source/migrations.md
Expand Up @@ -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
Expand Down

0 comments on commit 0dad3ed

Please sign in to comment.