Forum: Ruby on Rails Ruby Migration >> Foreign Keys

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
7b3f75b0be76dca5829b10f3570c8c65?d=identicon&s=25 Gladiator (Guest)
on 2007-07-12 13:25
(Received via mailing list)
I have two tables having many-to-many relationship.
I created a join table containing the primary keys of both tables.

Can any body tell me how use
Ruby migration for foreign keys....

Thanks in advance
Satish
63be0db1917c0299628460cab2177aaa?d=identicon&s=25 Roberto Gattinoni (gattox)
on 2007-07-12 14:48
Gladiator wrote:
> I have two tables having many-to-many relationship.
> I created a join table containing the primary keys of both tables.
>
> Can any body tell me how use
> Ruby migration for foreign keys....
>
> Thanks in advance
> Satish

Don't know what you mean. Do you mean something like this:

....
create_table :magazines_readers, :id => false do |t|
  t.column :magazine_id,  :integer
  t.column :reader_id, :integer
end

(see "Rails Recipes" pag. 104)

for a many-to-many relation between magazines and readers (a magazine
has many readers, a reader reads many magazines).

Roberto Gattinoni.
This topic is locked and can not be replied to.