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



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 ----


Suggest you try 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.