# Radio buttons not getting checked

**URL:** <https://www.ruby-forum.com/t/radio-buttons-not-getting-checked/131931>\
**Category:** Rails\
**Created:** [March 14, 2008, 3:11pm UTC](https://www.ruby-forum.com/t/radio-buttons-not-getting-checked/131931 "2008-03-14T15:11:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [March 14, 2008, 3:11pm UTC](https://www.ruby-forum.com/t/radio-buttons-not-getting-checked/131931/1 "2008-03-14T15:11:48Z")

</div>

I have the following code  
\<%= f.radio\_button “inc\_in\_exp\_sales”, “1” %\>Yes  
\<%= f.radio\_button “inc\_in\_exp\_sales”, “0” %\>No

works fine when adding a new record but when editing, the radio button  
is not check based on the record in the Database

Any ideas

---

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [March 14, 2008, 4:30pm UTC](https://www.ruby-forum.com/t/radio-buttons-not-getting-checked/131931/2 "2008-03-14T16:30:53Z")

</div>

sorry, if this sounds a bit newbie like,  
but your code should work, so the error must be  
in the controller

did you check, the result is stored in the db as expected?

---

<div class="post-metadata">

**Author:** ![Shawn\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/977dab/32.png) [@Shawn\_B](https://www.ruby-forum.com/u/Shawn_B)\
**Post date:** [March 14, 2008, 5:26pm UTC](https://www.ruby-forum.com/t/radio-buttons-not-getting-checked/131931/3 "2008-03-14T17:26:26Z")

</div>

I did and it is stored in the db as 1 or 0, actually fixed that issue  
by doing the following:

\<%= f.radio\_button “inc\_in\_exp\_sales”, true %\>Yes  
\<%= f.radio\_button “inc\_in\_exp\_sales”, false %\>No

Now I have a new issue

I have a partial that is being outputted through a collection  
statement. I wand to have a group of radio buttons but every time I  
try to output the partial the radio button get all grouped together no  
in separate groups

See [#75 Complex Forms Part 3 - RailsCasts](http://railscasts.com/episodes/75) and the comments at the bottom.

Harlan Crystal Feb 21, 2008 at 10:03

Is there any strategy for using this technique with radio buttons? The  
problem being that instead of having separate “button groups” for each  
task, you end up with one huge button group for all the radio buttons  
across tasks, because they all use the same “name” for radio widgets  
in each task.

I am having the same issue

On Mar 14, 12:30 pm, Thorsten M. \<rails-mailing-l…@andreas-
