Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:52:24+00:00 2026-05-23T18:52:24+00:00

I have a rails app I am working on that allows users to create

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:52:25+00:00Added an answer on May 23, 2026 at 6:52 pm

    Don’t do this:

    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.

    That sort of thing will just cause problems like making per-day queries a horrific ugly mess; how would you, for example, count how many events are available on Monday if you stored your days mashed into a single column?

    Instead, keep your seven booleans and add a simple convenience method to your model that returns the days in some more convenient format. Something like this perhaps:

    def days
      Date::DAYNAMES.map { |d| read_attribute(d.downcase) }
    end
    

    and then you can simply iterate over @event.days in your view and map the day numbers to names:

    <% @event.days.each_with_index do |on_day, i| %>
      <% if on_day %>
        <%= Date::DAYNAMES[i] %>
      <% end %>
    <% end %>
    

    The specific details of the days method and how you deal with it in your ERB will, of course, depend on your specific circumstances.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Rails app that uses STI to handle different types of Users,
I have a rails blog app that was working well.. However, I did some
We have already built a rails app that has several users and an image
I have a rails app that I have serving up XML on an infrequent
I have a Rails app that I have successfully tested with Mongrel and Webkit.
I have a Rails app that I need to deploy. Here are the facts:
I have a rails app that has picked up a bit of traction, but
I have a Rails app that sets a cookie and does a redirect to
I have a Rails app that will post some data to another Rails app.
I have a rails app that uses heavily js (over 1MB total). I'd like

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.