I’ve used Ruby’s Date::DAYNAMES function to save my days in a string using checkboxes.
- Date::DAYNAMES.each_with_index do |day,index|
= check_box_tag "promotion[days_#{index}]", index, false, :name => "promotion[days][]", :checked => (@promotion.days.include? index.to_s)
= day
Which gives a string like this:
"---\n- '0'\n- '1'\n- '4'\n"
In my view, I’ve tried using the following to display the day names but can’t get all of them. Only ever the first day.
= Date::DAYNAMES[@promotion.days.to_i]
Can someone show me how to get each selected day name out please.
The string looks like yaml. Try this in irb: