I'm having trouble displaying a list of days in a week in a form.
<%= form_for [@hourable, @hour] do |f| %>
<% days = []
Date::DAYNAMES.each_with_index { |x, i| days << [x, i] } %>
<% days.each_with_index do |day,index| %>
<div class="field">
<%= f.check_box day[0] %>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
I'm getting error
undefined method `Sunday' for #<Hour:0x007fe13c764010>
But if I just display
<%= day[0] %>
, it will give me a list Sunday, Monday, Tuesday, etc... to Saturday
What am I doing wrong here?
Thanks
f.label
to this. When I try to dof.label :day do
, withf.check_box :day
, all the input name is the same. How do I change the name so label will match with input? If I'm keeping the same:FIELD_NAME
or in my case is:day
, it is going to be all the same throughout the loop. – Exaggeration