[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Rails: Multi-Column Primary Key for ActiveRecord

Brian Takita

4/27/2005 9:41:00 PM

Hello,

Is there a way to set an ActiveRecord object to point to a table with a
multi-column primary key?

Thank you,
Brian Takita

5 Answers

Brian Takita

4/28/2005 3:08:00 PM

0

I get the impression that the current implementation does not support a
primary key with multiple columns.

Looking at base.rb, the primary_key variable is used in such a way that
a single column name is expected.

Brian Takita

4/28/2005 3:13:00 PM

0

This is regarding ActiveRecord 1.10.1

David Heinemeier Hansson

4/28/2005 7:42:00 PM

0

> Is there a way to set an ActiveRecord object to point to a table
> with a
> multi-column primary key?

Not really, no. Active Record was designed for a single column
primary key and that assumption runs pretty deep. AR is not a Data
Mapper, so you have to be within a reasonable vicinity of its
assumptions to enjoy it.
--
David Heinemeier Hansson
http://www.loudth... -- Broadcasting Brain
http://www.base... -- Online project management
http://www.rubyo... -- Web-application framework



Brian Takita

5/3/2005 6:23:00 AM

0

David,

First of all, your Rails framework is well done and has revamped my
interest in Ruby, which has been a very good thing. Thank you.

I was thinking that we can get around this single column key limitation
by adding a incrementing int column with a unique index to the table.
I havn't tried it, but it makes sense that it would work.

Brian

Brian Takita

5/3/2005 6:23:00 AM

0

David,

First of all, your Rails framework is well done and has revamped my
interest in Ruby, which has been a very good thing. Thank you.

I was thinking that we can get around this single column key limitation
by adding a incrementing int column with a unique index to the table.
I havn't tried it, but it makes sense that it would work.

Brian