# Many2many through and nested forms

**URL:** <https://www.ruby-forum.com/t/many2many-through-and-nested-forms/187755>\
**Category:** Rails\
**Created:** [April 28, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/many2many-through-and-nested-forms/187755 "2010-04-28T21:54:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [April 28, 2010, 9:54pm UTC](https://www.ruby-forum.com/t/many2many-through-and-nested-forms/187755/1 "2010-04-28T21:54:09Z")

</div>

I have the following:

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

```
  <% f.fields_for :features do |field|%>
     <div>
     <%= field.check_box :avaliable, { :class => 'check' },

```

“true”, “fales”%\>  
\<%= field.label :name %\>  
  
\<% end %\>

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

```
  t.timestamps
end

```

end

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

```
  t.timestamps
end

```

end

def self.down  
drop\_table :features  
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:** ![spokra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ba8739/32.png) [@spokra](https://www.ruby-forum.com/u/spokra)\
**Post date:** [April 29, 2010, 12:40am UTC](https://www.ruby-forum.com/t/many2many-through-and-nested-forms/187755/2 "2010-04-29T00:40:24Z")

</div>

found my own answer…

field.object.xxxxxx.xxxxxx
