Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Shopping_list
- include Mongoid::Document
- field :name, :type => String
- has_and_belongs_to_many :products
- end
- class Product
- include Mongoid::Document
- field :name, :type => String
- has_and_belongs_to_many :shopping_lists
- end
- a) The name of the product in a text box
- b) A series of checkboxes listing all of the products that they can check to add to that list.
- c) A submit button.
- def edit
- @shopping_list = Shopping_list.find(params[:id])
- render :action => 'edit'
- end
- <%= simple_form_for(@shopping_list) do |f| %>
- <%= f.input :name %>
- <%= f.input :articles, :as => :check_boxes %> #I know this is completely wrong. What do I do to fix?
- <%= f.button :submit %>
- <% end %>
- <%= simple_form_for(@shopping_list) do |f| %>
- <%= f.input :name %>
- <%= f.association :products,:collection => @shopping_list.products.collect{ |p| [p.name, p.id] }, :as => :check_boxes %>
- <%= f.button :submit %>
- <% end %>
Add Comment
Please, Sign In to add comment