# many2many through and nested forms.

**URL:** <https://discuss.rubyonrails.org/t/many2many-through-and-nested-forms/51266>\
**Category:** rubyonrails-talk\
**Created:** [April 28, 2010, 7:52pm UTC](https://discuss.rubyonrails.org/t/many2many-through-and-nested-forms/51266 "2010-04-28T19:52:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gumby](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@Gumby](https://discuss.rubyonrails.org/u/Gumby)\
**Post date:** [April 28, 2010, 7:52pm UTC](https://discuss.rubyonrails.org/t/many2many-through-and-nested-forms/51266/1 "2010-04-28T19:52:32Z")

</div>

I have the following:

class Lot \< ActiveRecord::Base &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has\_many :images &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has\_many :features &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has\_many :feature\_labels, :through =\> :features &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;has\_many :photos, :through =\> :images &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;accepts\_nested\_attributes\_for :photos &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;accepts\_nested\_attributes\_for :features end

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% f.fields\_for :features do |field|%\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<div\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= field.check\_box :avaliable, { :class =\> 'check' }, "true", "fales"%\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<%= field.label :name %\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\</div\> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\<% end %\>

class CreateFeatureLabels \< ActiveRecord::Migration &nbsp;&nbsp;def self.up &nbsp;&nbsp;&nbsp;&nbsp;create\_table :feature\_labels do |t| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.string :name

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.timestamps &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

&nbsp;&nbsp;def self.down &nbsp;&nbsp;&nbsp;&nbsp;drop\_table :feature\_labels &nbsp;&nbsp;end end class CreateFeatures \< ActiveRecord::Migration &nbsp;&nbsp;def self.up &nbsp;&nbsp;&nbsp;&nbsp;create\_table :features do |t| &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.integer :lot\_id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.integer :feature\_label\_id &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.boolean :avaliable

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;t.timestamps &nbsp;&nbsp;&nbsp;&nbsp;end &nbsp;&nbsp;end

&nbsp;&nbsp;def self.down &nbsp;&nbsp;&nbsp;&nbsp;drop\_table :features &nbsp;&nbsp;end end

the form works and the controller saves the data correctly. I cannot figure out home to get the correct label. can someone give me some pointers. :\>

---

<div class="post-metadata">

**Author:** ![Gumby](https://avatars.discourse-cdn.com/v4/letter/g/bb73d2/32.png) [@Gumby](https://discuss.rubyonrails.org/u/Gumby)\
**Post date:** [April 28, 2010, 10:39pm UTC](https://discuss.rubyonrails.org/t/many2many-through-and-nested-forms/51266/2 "2010-04-28T22:39:05Z")

</div>

found my own answer..

field.object.xxxxxx.xxxxxx
