Forum: Ruby on Rails Primary Key Field name - Problem

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.
Devi R. (Guest)
on 2009-03-28 14:19
Dear All,

       Can i declare a primary key field name as us_id? instead of Id.
Regards
Devi.R
Craig D. (Guest)
on 2009-03-28 14:41
(Received via mailing list)
You can call set_primary_key:

class MyModel < ActiveRecord::Base
  set_primary_key "us_id"
end

See:
http://www.railsbrain.com/api/rails-2.3.2/doc/inde...

Regards,
Craig


--
Craig D.
Mutually Human Software
http://mutuallyhuman.com
Conrad T. (Guest)
on 2009-03-28 14:56
(Received via mailing list)
On Sat, Mar 28, 2009 at 5:40 AM, Craig D.
<removed_email_address@domain.invalid>wrote:

> Craig
>
>
> --
> Craig D.
> Mutually Human Software
> http://mutuallyhuman.com
>
>
If you do decide to override the primary key, it will be your
responsibility
to set it to a unique before
you perform a save operation on a new row.

-Conrad
Conrad T. (Guest)
on 2009-03-28 14:57
(Received via mailing list)
On Sat, Mar 28, 2009 at 5:55 AM, Conrad T. 
<removed_email_address@domain.invalid>
wrote:
Devi R. (Guest)
on 2009-03-30 07:47
Thanks you for your reply. Now it's working.
This topic is locked and can not be replied to.