I have a rails app I am working on that allows users to create a schedule. In doing so, they should be able to select on which days of the week an event occurs. The way I was planning on doing this in a form was a checkbox next to every, weekday, like so:
<%= f.check_box :monday %> <%= f.label :monday %>
<%= f.check_box :tuesday %> <%= f.label :tuesday %>
<%= f.check_box :wednesday %> <%= f.label :wednesday %>
etc...
However, It occured to me that this probably isn't a very efficient way of handling this, storing each date as a boolean value in the database. It will be very difficult to display the dates in the 'show' view; I'll have to do something like
Event Dates:
<% if @event.monday? %>
Monday
<% end %>
<% if @event.tuesday? %>
Tuesday
<% end %>
<% if @event.wednesday? %>
Wednesday
<% end %>
Which seems less than ideal to me.
My other idea would be to just create one string column in the database that holds all of the event dates, using attr_accesors and a model method to create the string after_create. However, in this case, how will users be able to edit the Event?
It got me thinking, there must be some sort of best practice here that I don't know about (I've never tried to create something with this type of structure before).
Any advice?
Thanks!