Forum: Ruby on Rails Question about belongs_to

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Elias O. (Guest)
on 2009-02-18 17:59
(Received via mailing list)
Hello guys,

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

table users

table apps

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,

Frederick C. (Guest)
on 2009-02-18 18: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.

This topic is locked and can not be replied to.