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

  • SEARCH
  • Home
  • 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 5984961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:27:29+00:00 2026-05-22T22:27:29+00:00

I was wondering how check boxes work in Rails? What would the table be

  • 0

I was wondering how check boxes work in Rails? What would the table be inside of the database( integer, string,etc)? How would you give 3 different values to check boxes and the user only can choose 1(favorite color: red,green or blue)?

I’m new to rails and it would help to have an explanation from the beginning to end as i see a lot of examples but they don’t explain everything from the start.

Thank you.

  • 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-22T22:27:30+00:00Added an answer on May 22, 2026 at 10:27 pm

    There is a distinction between checkboxes and the database. Checkboxes are HTML. Database is connected to your Models, and it has nothing to do with checkboxes.

    When you use a checkbox in your HTML view, your form will send some parameter. By default this parameter will have the value “1” (as String). Rails helpers also create an additional hidden input, which sends the value “0” with the same name as the checkbox input. Parsing the parameters Rails picks the first value, so the given parameter is assigned a value “1” if the checkbox has been checked, and the value “0” if it has not.

    Now, the value saved in the database depends on the type of the attribute in your model. If you defined a given field as boolean, then it will be stored as boolean (there is some magic, since the String “0” is not considered ‘false’ in ruby), if you define the attribute as integer, then it will have the value 1 or 0, and if it’s a String, you will have “1” or “0”.

    About these 3 values for checkbox, I would use a <select> or a radio-button.

    Red:   <input type="radio" name="colour" value="red" checked="checked"/>
    Green: <input type="radio" name="colour" value="green" />
    Blue:  <input type="radio" name="colour" value="blue" />
    

    See the ActionView::Helpers::FormHelper#radio_button method.

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

Sidebar

Related Questions

I am wondering what methods people are using for validating check boxes in ASP.NET
I was wondering how you would check if there are multiple instances of an
I'm wondering how I can check if a string contains either value1 or value2?
I was wondering how to check whether a variable is a class (not an
I was wondering if it which is faster when trying to, for example, check
Wondering if anyone has gotten the infamous database is locked error from Trac and
We have 10 Linux boxes that must run 100 different tasks each week. These
I'm wondering if there's a better way to check out the initial version of
I was wondering, how I check if the height of a div is greater
I was wondering if there's a remote file availability check using Flex-AIR. Not a

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.