Forum: Ruby on Rails ID not primary key with not unique values

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.
10f7e00c1c5c60e2173995eb16f4ffc7?d=identicon&s=25 pepe (Guest)
on 2009-05-26 18:11
(Received via mailing list)
Sorry for the re-post. Nobody has even answered "no, can't do".

I have an ID column in a legacy table of type STRING and could contain
not unique values. Is there a way of disabling the convention of ID
being the primary key? How can I assign the values I need to the ID
column without using SQL, which I already know would work?

ruby: 1.8.6
rails: 2.3.2
Database: Oracle 10g

Thanks.

Pepe
D6434aa0b7b350f8c3ed0119d81b2ead?d=identicon&s=25 Roy Pardee (rpardee)
on 2009-05-26 18:20
(Received via mailing list)
I believe the primary_key directive will tell AR what field to use as
the actual PK.  Something like:

  class MyClass < AR::Base
    primary_key :actual_pk_field_name
  end

Hopefully AR would then then ignore the id field.
5772c599ccab3081e0fffb1d54f3b6de?d=identicon&s=25 Andrew Timberlake (andrewtimberlake)
on 2009-05-26 18:21
(Received via mailing list)
On Tue, May 26, 2009 at 6:11 PM, pepe <Pepe@betterrpg.com> wrote:
> Database: Oracle 10g
>
> Thanks.
>
> Pepe


Yup, can do :-)
See: http://api.rubyonrails.org/classes/ActiveRecord/Ba...

Technically a primary key is not a primary key if it can contain
duplicate (not unique) values

Andrew Timberlake
http://ramblingsonrails.com

http://MyMvelope.com - The SIMPLE way to manage your savings
This topic is locked and can not be replied to.