# How to pass Radio Button selection to the controller?

**URL:** <https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543>\
**Category:** Rails\
**Created:** [February 23, 2007, 4:01am UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543 "2007-02-23T04:01:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [February 23, 2007, 4:01am UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543/1 "2007-02-23T04:01:41Z")

</div>

Hey guys, I have a loop that generates multiple radio buttons, here’s  
the code:

\<% checked = true %\>  
\<% for address in @customer.addresses %\>  
\<%= radio\_button\_tag(“address”, address.id, checked = checked)  
%\>  
\<% checked = false %\>  
\<% end %\>

\<%= link\_to ‘Confirm Order \>\>’, :controller =\> ‘store’, :action =\>  
‘confirm\_order’, :customer\_id =\> @customer , :address\_id = ??? %\>

How can I pass the selected address button to the controller ??

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [February 23, 2007, 4:44am UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543/2 "2007-02-23T04:44:11Z")

</div>

nvm … I found the problem 🙂

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [February 23, 2007, 5:01am UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543/3 "2007-02-23T05:01:32Z")

</div>

Swaraj S. wrote:

> nvm … I found the problem 🙂

Please tell us what the solution was. Otherwise, you just left a false  
trail  
in the archives. They are important because nothing else documents most  
of  
the hard details around here!

–  
Phlip  
[Redirecting...](http://www.greencheese.us/ZeekLand) ← NOT a blog!!!

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [March 31, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543/4 "2007-03-31T18:21:44Z")

</div>

please send me the solution cz i face the same proplem  
& please copy the mail to my private mail cz i dont check the group

On Feb 23, 5:01 am, Swaraj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [April 2, 2007, 2:33am UTC](https://www.ruby-forum.com/t/how-to-pass-radio-button-selection-to-the-controller/86543/5 "2007-04-02T02:33:24Z")

</div>

The simplest way is to use a form submit instead. (You can refer to the  
selection with params[:address].)

If using form is not acceptable, you may create a javascript that would  
update the URL when the radio buttons are clicked.
