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

Discussion in 'Ruby' started by Greg Hauptmann, Oct 30, 2008.

  1. 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
    Greg Hauptmann, Oct 30, 2008
    #1
    1. Advertising

  2. Re: why doesn't this "belongs_to" line of code, using optionsoverride, not work??? (need help using

    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.
    --
    Posted via http://www.ruby-forum.com/.
    Brian Candler, Oct 30, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    880
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,850
    Smokey Grindel
    Dec 2, 2006
  3. Utkado
    Replies:
    2
    Views:
    2,101
  4. dave.new
    Replies:
    0
    Views:
    149
    dave.new
    May 22, 2006
  5. Aryk Grosz

    self referential belongs_to

    Aryk Grosz, Jun 26, 2008, in forum: Ruby
    Replies:
    0
    Views:
    95
    Aryk Grosz
    Jun 26, 2008
Loading...

Share This Page