Forum: Ruby on Rails Question about belongs_to

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.
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2009-02-18 16:59
(Received via mailing list)
Hello guys,

I am trying to create a belongs_to relation between 2 tables.

table users
id
login
.

table apps
id
admin
.
.

I need to create a belongs_to relation on the App model. The admin
column in apps references the user login. I will have used user_id
instead of the login name but I can't change this right now (so they
said), so I have to try to make the relationship as it is. I did the
following but I don't know how to put that admin should reference the
User login column:

belongs_to :owner, :class_name = "User", :foreign_key => "admin"

Help please any,

Elías
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-18 17:56
(Received via mailing list)
On 18 Feb 2009, at 15:56, elioncho wrote:

> table apps
> User login column:
>
> belongs_to :owner, :class_name = "User", :foreign_key => "admin"
>
ActiveRecord doesn't support that.

Fred
This topic is locked and can not be replied to.