I am a newbie with ruby on rails and I need to add a collection_select that display the quantity of book to sell from 1 to the quantity saved in the database
for example I have 4 examplaries of a certain book, so i need to display a collecion select for that book from 1 t 4, to give the user the possibility to sell he quantit he needs from that book. I know that I am doing something stupidly but this is my suggestion that does not work
<%= f.select :book, :book_id, options_for_select(@books.quantity.map{ |s| [s, s ] }) %>
any suggestion please?
I doubt that your data model is the best way to solve this problem (I would suggest an order model with line_items) but for your given model this is the solution:
<%= f.select :quantity, ((0..@books.count).map {|i| [i,i] }) %>