# check box tag

**URL:** <https://discuss.rubyonrails.org/t/check-box-tag/33525>\
**Category:** rubyonrails-talk\
**Created:** [August 22, 2008, 9:54pm UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525 "2008-08-22T21:54:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felipe\_Vergara](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@Felipe\_Vergara](https://discuss.rubyonrails.org/u/Felipe_Vergara)\
**Post date:** [August 22, 2008, 9:54pm UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/1 "2008-08-22T21:54:49Z")

</div>

Need some help please!!!

I have a hash that contain a group of post, i render this hash on html. I want that with a checkbox the person can select the post to save it on the database.

Somebody know how to do this, i dont understant the check\_box\_tag.

---

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [August 23, 2008, 2:00pm UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/2 "2008-08-23T14:00:14Z")

</div>

> Need some help please!!!
> 
> I have a hash that contain a group of post, i render this hash on  
> html. I want that with a checkbox the person can select the post to  
> save it on the database.
> 
> Somebody know how to do this, i dont understant the check\_box\_tag.

check\_box\_tag isn't particularly magic. It does just create a checkbox  
with the specified name. What's in your hash (what are the keys/values)

Fred

---

<div class="post-metadata">

**Author:** ![Felipe\_Vergara](https://avatars.discourse-cdn.com/v4/letter/f/d9b06d/32.png) [@Felipe\_Vergara](https://discuss.rubyonrails.org/u/Felipe_Vergara)\
**Post date:** [August 24, 2008, 3:28pm UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/3 "2008-08-24T15:28:15Z")

</div>

The hash contains an array with post objects, id, title, body

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 17, 2011, 5:42am UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/4 "2011-05-17T05:42:24Z")

</div>

html.erb

\<%form\_for(:person do |f|)%\> \<%= check\_box(:person,:permanent\_employee,:options=\>{},:on\_value =\> "1",:off\_value =\> "0")%\> \<%end\>

controller edit\_method

---

<div class="post-metadata">

**Author:** ![11155](https://avatars.discourse-cdn.com/v4/letter/1/d26b3c/32.png) [@11155](https://discuss.rubyonrails.org/u/11155)\
**Post date:** [May 17, 2011, 5:43am UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/5 "2011-05-17T05:43:10Z")

</div>

html.erb

\<%form\_for(:person do |f|)%\> \<%= check\_box(:person,:permanent\_employee,:options=\>{},:on\_value =\> "1",:off\_value =\> "0")%\> \<%end\>

controller edit\_method

---

<div class="post-metadata">

**Author:** ![Naren1](https://avatars.discourse-cdn.com/v4/letter/n/a4c791/32.png) [@Naren1](https://discuss.rubyonrails.org/u/Naren1)\
**Post date:** [May 17, 2011, 5:48am UTC](https://discuss.rubyonrails.org/t/check-box-tag/33525/6 "2011-05-17T05:48:35Z")

</div>

a small correction in your form

\<%form\_for(:person) do |f|%\>
