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.
57f355c4d8bab93d67dfbd1691ab0be4?d=identicon&s=25 Devi Rv (devirv)
on 2009-03-28 13:19
Dear All,

       Can i declare a primary key field name as us_id? instead of Id.
Regards
Devi.R
B14575f0ca69f10938fdd67e7156e0e1?d=identicon&s=25 Craig Demyanovich (Guest)
on 2009-03-28 13: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 Demyanovich
Mutually Human Software
http://mutuallyhuman.com
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-03-28 13:56
(Received via mailing list)
On Sat, Mar 28, 2009 at 5:40 AM, Craig Demyanovich
<cdemyanovich@gmail.com>wrote:

> Craig
>
>
> --
> Craig Demyanovich
> 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
40db9e75b3f5899258e3bdc0c9210154?d=identicon&s=25 Conrad Taylor (conradwt)
on 2009-03-28 13:57
(Received via mailing list)
On Sat, Mar 28, 2009 at 5:55 AM, Conrad Taylor <conradwt@gmail.com>
wrote:
57f355c4d8bab93d67dfbd1691ab0be4?d=identicon&s=25 Devi Rv (devirv)
on 2009-03-30 05:47
Thanks you for your reply. Now it's working.
This topic is locked and can not be replied to.