Ruby on Rails Wednesday, April 28, 2010

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 %>
</div>
<% 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. :>

--
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@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment