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'm just wondering on how would you check java codes like System.Out.println(hi); it should
I was wondering whether there is a way to check when the database was
I am wondering what methods people are using for validating check boxes in ASP.NET
I'm currently building a room booking system and was wondering how to check if
Just wondering for user permission check, Should you keep the permission in the session
Just wondering is there any way I can check whether the url links to
I've been wondering how I could check all my parameters efficiently in any function
I was wondering if it was possible to check if the file test.txt is
I was wondering if it is possible to check for a particular sheets for
I was wondering if the codes below are the correct way to check for

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.