Greg Hauptmann
2009-Jan-22 03:31 UTC
how can I set attributes in the intermediate table for a many-to-many situation??? (e.g. when trying to use the << method)
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/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---