Forum: Ruby on Rails Using multiple columns as primary key

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.
8aa68df8d14eff5681c8e87a073e8cca?d=identicon&s=25 Gitte Wange (Guest)
on 2006-01-04 00:45
(Received via mailing list)
Hi!

I'm trying to use a primary key made up of two columns in my model's
table.
But looking at the docs, it looks like ActiveRecord only supports using
one field as primary key.

Can anyone point me in a direction of this or verify that it's not
supported?

Greetings,
Gitte Wange
17acfbd3a05cfb59e0543235cc0a813b?d=identicon&s=25 joshua (Guest)
on 2006-01-04 02:03
Composite primary keys are not supported... yet.  But keep an eye on
Edge Rails.

Gitte Wange wrote:
> Hi!
>
> I'm trying to use a primary key made up of two columns in my model's
> table.
> But looking at the docs, it looks like ActiveRecord only supports using
> one field as primary key.
>
> Can anyone point me in a direction of this or verify that it's not
> supported?
>
> Greetings,
> Gitte Wange
5d15c6821f3c3054c04b85471824ba7c?d=identicon&s=25 xiheng xu (Guest)
on 2006-02-08 22:49
(Received via mailing list)
Hi I'm a total beginner with either Ruby or Rails.

I am having the same issue and was also looking for a confirmation on
this matter.  Since multi-column primary keys are not currrently
supported, and the legacy table I have uses four varchar columns as the
primary key.  As a work-around during prototyping, I created a view that
does the following:

CREATE VIEW WorkAround
AS
SELECT f1 + '-' + f2 + '-' + f3 + '-' + f4
AS id
FROM LegacyTable

It's not perfect but it suffcies for my purposes.

By the way, can anybody tell me what happened to http://
manuals.rubyonrails.com?
This topic is locked and can not be replied to.