0

I have a rails project with Products and Orders in a HABTM relationship. In the form for orders, I want a user to be able to click on a button and have it preselect a number of products (some of them in more than one quantity). I've tried using checkboxes but this doesn't allow for a user to select two quantities of the same product.

I know that on the controller side, it won't have a problem if there are, for example, multiple instances of the same product_id, it'll just associate those id's multiple times with that order. However, I can't think of a way to do this on the view/form side if all I can work with are checkboxes.

Any ideas?

maschwenk
  • 569
  • 1
  • 9
  • 20

1 Answers1

2

Hey is your code same as this in your form page

<div>
  <%= check_box_tag "product[order_ids][]", order.id , @product.orders.include?(order) %>
  <%= order .name %>
</div>
Ayush
  • 3,989
  • 1
  • 26
  • 34