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. :>