Forum: Ruby on Rails how can I set attributes in the intermediate table for a many-to-many situation??? (e.g. when tryin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5df9fcd7ef4c3c937435d7d6adeab2a?d=identicon&s=25 Greg Hauptmann (Guest)
on 2009-01-22 04:32
(Received via mailing list)
Hi,

It seems for the model scenario I have below if there was NO "amount"
field
on AiAllocation I could go:
    <account item>.business_items << <business item>

QUESTION: What's the easiest way to allocate an account item to a
business
item in this case.  I really want something like:
    <account item>.business_items << <business item>, <AiAllocation
amount
value>


*Model Scenario (see below)*

class AccountItem < ActiveRecord::Base
  has_many :ai_allocations
  has_many :business_items, :through => :ai_allocations
...

class AiAllocation < ActiveRecord::Base
 * # Amount field *
  belongs_to :account_item
  belongs_to :business_item
...

class BusinessItem < ActiveRecord::Base
  has_many :ai_allocations
  has_many :account_items, :through => :ai_allocations




thanks


--
Greg
http://blog.gregnet.org/
This topic is locked and can not be replied to.