# How can I set attributes in the intermediate table for a many-to-many situation? (e.g. when tryin

**URL:** <https://www.ruby-forum.com/t/how-can-i-set-attributes-in-the-intermediate-table-for-a-many-to-many-situation-e-g-when-tryin/158328>\
**Category:** Rails\
**Created:** [January 22, 2009, 4:32am UTC](https://www.ruby-forum.com/t/how-can-i-set-attributes-in-the-intermediate-table-for-a-many-to-many-situation-e-g-when-tryin/158328 "2009-01-22T04:32:41Z")\
**Posts on this page:** 1\
**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:** [January 22, 2009, 4:32am UTC](https://www.ruby-forum.com/t/how-can-i-set-attributes-in-the-intermediate-table-for-a-many-to-many-situation-e-g-when-tryin/158328/1 "2009-01-22T04:32:41Z")

</div>

Hi,

It seems for the model scenario I have below if there was NO “amount”  
field  
on AiAllocation I could go:  
.business\_items \<\<

QUESTION: What’s the easiest way to allocate an account item to a  
business  
item in this case. I really want something like:  
.business\_items \<\< ,

_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/](http://blog.gregnet.org/)
