I've a little array:
@dates= ['2013-11-01', '2013-11-02', '2013-11-03', '2013-11-04', '2013-11-05']
how can i put these array in an collection_select in the view? I tried:
...
<%= f.collection_select :day, Day.order(:date), :id, @dates, include_blank: false %>
...
Assuming that you mean to use the date strings for both the value (returned from form) and text (displayed in drop-down) of the select then
= f.collection_select :day, @dates, :to_s, :to_s, include_blank: false
This will pass :to_s to each element of the the @dates collection and use the results for the text (param 3) and value (param 4) of the select.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With