Why don't you try googling a little. All you need here
inside the loop <% for r in @readings %>
is --------------------------
<%= radio_button_tag 'contact_preference_id', "#{r.id}", false, :class=>
"classname_if_any"%>
RED is the name of the radio buttons, must be same for all the other radio
buttons to facilitate, User must be able to select only one of the radio
buttons in the current_readings list.
GREEN is the value of the radio button, i.e. the id of the current_reading.
It will be different for every radio button.
BLUE is whether that radio button should be checked or not. But initially
you should keep it false only. When user wish to he might select one of
them.
GREY is the class variable you want to set to apply some css class to
improve the look of the radio button.
......#Rest of the code you already have below
And inside the weather_controller
in def index action,
do something like -
if request.post?
#That means someone clicked view Details link.
And you check the value of params[:contact_preference_id], will give you id
of the selected radio button.
good luck,
Nitin.
On Wed, Mar 10, 2010 at 4:06 PM, Veena Jose <[email protected]> wrote:
>
> Hai friends,
>
> I am really new to ROR
> I have some radiobuttons...If user select a radiobutton i want to get
> the id of the selected radio button to be passed as an id to the index
> page of weather controller on clicking the button "view Details"
> I don't know how to pass the id? Can you please help me out.
>
> View
>
> <% for r in @readings %>
> <%= radio_button :contact_preference, "value", :tabindex =>r.id %>
> <%=h r.station.province %>
> <%end%>
> <%= button_to "View Details", :controller => "weather", :action =>
> "index" %>
>
> Thanks,
> Veena
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<rubyonrails-talk%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.