daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Jan 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class Shopping_list
  2.   include Mongoid::Document
  3.   field :name, :type => String
  4.   has_and_belongs_to_many :products
  5. end
  6.    
  7. class Product
  8.   include Mongoid::Document
  9.   field :name, :type => String
  10.   has_and_belongs_to_many :shopping_lists
  11. end
  12.    
  13. a) The name of the product in a text box
  14. b) A series of checkboxes listing all of the products that they can check to add to that list.
  15. c) A submit button.
  16.    
  17. def edit
  18.   @shopping_list = Shopping_list.find(params[:id])
  19.   render :action => 'edit'
  20. end
  21.    
  22. <%= simple_form_for(@shopping_list) do |f| %>
  23.     <%= f.input :name %>
  24.     <%= f.input :articles, :as => :check_boxes %> #I know this is completely wrong. What do I do to fix?
  25.     <%= f.button :submit %>
  26. <% end %>
  27.    
  28. <%= simple_form_for(@shopping_list) do |f| %>
  29.    <%= f.input :name %>
  30.    <%= f.association :products,:collection => @shopping_list.products.collect{ |p| [p.name, p.id] }, :as => :check_boxes %>
  31.    <%= f.button :submit %>
  32. <% end %>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top