# Question about belongs\_to

**URL:** <https://www.ruby-forum.com/t/question-about-belongs-to/160667>\
**Category:** Rails\
**Created:** [February 18, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/question-about-belongs-to/160667 "2009-02-18T16:59:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [February 18, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/question-about-belongs-to/160667/1 "2009-02-18T16:59:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![elioncho](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed8c4c/32.png) [@elioncho](https://www.ruby-forum.com/u/elioncho)\
**Post date:** [February 18, 2009, 5:56pm UTC](https://www.ruby-forum.com/t/question-about-belongs-to/160667/2 "2009-02-18T17:56:30Z")

</div>

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
