# Why doesn't this "belongs\_to" line of code, using options override, not work? (need help using bel

**URL:** <https://www.ruby-forum.com/t/why-doesnt-this-belongs-to-line-of-code-using-options-override-not-work-need-help-using-bel/152184>\
**Category:** Ruby\
**Created:** [October 30, 2008, 10:23pm UTC](https://www.ruby-forum.com/t/why-doesnt-this-belongs-to-line-of-code-using-options-override-not-work-need-help-using-bel/152184 "2008-10-30T22:23:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 30, 2008, 10:23pm UTC](https://www.ruby-forum.com/t/why-doesnt-this-belongs-to-line-of-code-using-options-override-not-work-need-help-using-bel/152184/1 "2008-10-30T22:23:08Z")

</div>

Hi,

Anyone able to help out in how you use “belongs\_to” options so that I  
can have a 2nd attribute that also belongs to an associated table. My  
recurring items class belongs to a “transaction”, however I also want  
a secondary recurring item field “journal\_source\_id” to be able to  
reference a “bank\_account” item.

## The following doesn’t quite seem to work?

## belongs\_to :journal\_source, # I made this name up, i.e. it isn’t actually in a table. It’s the “journal\_source\_id” field that is in the recurring table :class\_name =\> “BankAccount”, :foreign\_key =\> “journal\_source\_id”

Background below:

---- recurring class ----  
belongs\_to :bank\_account # recurrance associated with bank account  
belongs\_to :journal\_source, # HELP ME HERE: Want to have another  
reference to a “bank acount” here  
:class\_name =\> “BankAccount”,  
:foreign\_key =\> “journal\_source\_id”

– recurrings table ----

# id :integer(4) not null, primary key

# bank\_account\_id :integer(4) not null

# journal\_source\_id :integer(4) \<==== THIS IS THE ONE

---- bankaccounts table ----  
id  
.  
.

---

<div class="post-metadata">

**Author:** ![greg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/71c47a/32.png) [@greg](https://www.ruby-forum.com/u/greg)\
**Post date:** [October 30, 2008, 11:45pm UTC](https://www.ruby-forum.com/t/why-doesnt-this-belongs-to-line-of-code-using-options-override-not-work-need-help-using-bel/152184/2 "2008-10-30T23:45:22Z")

</div>

Suggest you try [Ruby on Rails — Community](http://rubyonrails.com/community)

ActiveRecord is a sufficiently large project in its own right that it  
has its own mailing lists, and you’re more likely to find experts there.
