# Foreign key

**URL:** <https://www.ruby-forum.com/t/foreign-key/191251>\
**Category:** Rails\
**Created:** [July 8, 2010, 9:41am UTC](https://www.ruby-forum.com/t/foreign-key/191251 "2010-07-08T09:41:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mailtorajuit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed8c4c/32.png) [@mailtorajuit](https://www.ruby-forum.com/u/mailtorajuit)\
**Post date:** [July 8, 2010, 9:41am UTC](https://www.ruby-forum.com/t/foreign-key/191251/1 "2010-07-08T09:41:22Z")

</div>

HI all,

In my application i have 2 tables, 1.logins and 2. credits.

logins contains customer details and credits has credit detils of  
customers.

i have given custom foreign key while migrating database for credits  
table instead of logins\_id i have given as log\_id.

how to mention this in model associtations

---

<div class="post-metadata">

**Author:** ![mailtorajuit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed8c4c/32.png) [@mailtorajuit](https://www.ruby-forum.com/u/mailtorajuit)\
**Post date:** [July 8, 2010, 9:53am UTC](https://www.ruby-forum.com/t/foreign-key/191251/2 "2010-07-08T09:53:45Z")

</div>

On 8 July 2010 08:41, Rajkumar S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> In my application i have 2 tables, 1.logins and 2. credits.
> 
> how to mention this in model associtations

You’ll find lots of “getting started” guides online - no sense  
rewriting them here:  
[http://www.google.co.uk/search?q=getting+started+with+ruby+on+rails](http://www.google.co.uk/search?q=getting+started+with+ruby+on+rails)

---

<div class="post-metadata">

**Author:** ![mailtorajuit](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed8c4c/32.png) [@mailtorajuit](https://www.ruby-forum.com/u/mailtorajuit)\
**Post date:** [July 8, 2010, 9:57am UTC](https://www.ruby-forum.com/t/foreign-key/191251/3 "2010-07-08T09:57:51Z")

</div>

On 8 July 2010 08:52, Michael P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> On 8 July 2010 08:41, Rajkumar S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > In my application i have 2 tables, 1.logins and 2. credits.
> > 
> > how to mention this in model associtations
> 
> You’ll find lots of “getting started” guides online - no sense  
> rewriting them here:  
> [getting started with ruby on rails - Google Search](http://www.google.co.uk/search?q=getting+started+with+ruby+on+rails)

Particularly the guides at [Ruby on Rails Guides](http://guides.rubyonrails.org/index.html).  
There is one on ActiveRecord Associations which should contain what  
you want to know (assuming you have worked through the Getting Started  
one first).

Colin
