# Beginner

**URL:** <https://www.ruby-forum.com/t/beginner/168704>\
**Category:** Rails\
**Created:** [May 24, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/beginner/168704 "2009-05-24T18:37:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![quark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5e9695/32.png) [@quark](https://www.ruby-forum.com/u/quark)\
**Post date:** [May 24, 2009, 6:37pm UTC](https://www.ruby-forum.com/t/beginner/168704/1 "2009-05-24T18:37:46Z")

</div>

Hello everyone,  
I’m new to RoR, and I have a silly problem I can’t solve.  
I have a User class, with some attributes (login, password, online…).  
In the login form, I have a checkbox. I want to change the value of the  
online attribute if this checkbox is checked. I know it must be  
something like (if params[:checkboxname]==true).  
Does anyone how to do that?

thanks a lot

---

<div class="post-metadata">

**Author:** ![quark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5e9695/32.png) [@quark](https://www.ruby-forum.com/u/quark)\
**Post date:** [May 24, 2009, 7:30pm UTC](https://www.ruby-forum.com/t/beginner/168704/2 "2009-05-24T19:30:35Z")

</div>

if params[:checkbox]

This checks if that params is true(true/false, 1/0) or not, but how  
did you do you checkbox code? If its just a form\_for … do |f|  
f.checkbox(:checkbox) you should be ok.

---

<div class="post-metadata">

**Author:** ![quark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/q/5e9695/32.png) [@quark](https://www.ruby-forum.com/u/quark)\
**Post date:** [May 24, 2009, 8:16pm UTC](https://www.ruby-forum.com/t/beginner/168704/3 "2009-05-24T20:16:33Z")

</div>

On May 24, 6:29 pm, Freddy A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> if params[:checkbox]
> 
> This checks if that params is true(true/false, 1/0)

both 1 and 0 are true in ruby 🙂  
If you are doing this by hand you will need to compare params  
[:checkbox] to the value that gets submitted. if you are using the  
check\_box helper then by default the value will be “0” or  
“1” (strings, not integers). If you are using check\_box\_tag or  
crafting the html by hand then it is slightly more troublesome as if  
the check box is not ticked there will be no value in the params hash.  
If you are using the check\_box helper it might be appropriate to just  
pass the appropriate part of the params hash to update\_attributes.

Fred

or not, but how
