# CheckBox and Ruby on Rails

**URL:** <https://www.ruby-forum.com/t/checkbox-and-ruby-on-rails/171203>\
**Category:** Rails\
**Created:** [June 28, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/checkbox-and-ruby-on-rails/171203 "2009-06-28T15:07:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [June 28, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/checkbox-and-ruby-on-rails/171203/1 "2009-06-28T15:07:58Z")

</div>

I have two questions:

1. I have a checkbox on a form and after submit I need to check the  
status of the checkbox. Any idea how to see what the checkbox is set  
to? I am assuming this must be done in the controller or model but  
cannot figure it out.

2. On load I am checking for a cookie and need to determine if the  
checkbox should be checked or unchecked. Is there a way for me to do  
this from the controller and actually set the checkbox to checked or  
unchecked.

---

<div class="post-metadata">

**Author:** ![david](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/aeb1de/32.png) [@david](https://www.ruby-forum.com/u/david)\
**Post date:** [June 28, 2009, 5:47pm UTC](https://www.ruby-forum.com/t/checkbox-and-ruby-on-rails/171203/2 "2009-06-28T17:47:17Z")

</div>

David wrote:

> I have two questions:
> 
> 1. I have a checkbox on a form and after submit I need to check the  
> status of the checkbox. Any idea how to see what the checkbox is set  
> to? I am assuming this must be done in the controller or model but  
> cannot figure it out.

The value of the checkbox will be available in the params hash, just  
like all the other form fields.

> 1. On load I am checking for a cookie and need to determine if the  
> checkbox should be checked or unchecked. Is there a way for me to do  
> this from the controller and actually set the checkbox to checked or  
> unchecked.

If you’re using form\_for @object, just set the appropriate field in  
@object in the controller.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
