Created
March 2, 2012 19:43
-
-
Save itsNikolay/1960802 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= form_for (@products) do |f| %> | |
<%= f.label "Colors" %> | |
<% for color in Color.all %> | |
<%= check_box_tag 'product[color_ids][]', color.id, | |
@product.color_ids.include?(color.id), :id => dom_id(color) %> | |
<%= label_tag dom_id(colore), color.name, :class => "check_box_label" %> | |
<br /> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Place < ActiveRecord::Base | |
has_and_belongs_to_many :products | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Contract < ActiveRecord::Base | |
has_and_belongs_to_many :colors | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create_table "products", :force => true do |t| | |
t.string "color" | |
end | |
create_table "products_colors", :id => false, :force => true do |t| | |
t.integer "product_id" | |
t.integer "color_id" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment