Radio Button Defailt Value?

I have:

<%= radio_button ‘foo’, ‘bar_id’, ‘1’ %>
<%= radio_button ‘foo’, ‘bar_id’, ‘2’ %>
<%= radio_button ‘foo’, ‘bar_id’, ‘3’ %>

I would like to have option #3 be selected if foo.bar_id is nil. Is
there a way to do that?

In your controller, do

@foo.bar_id = 3

or

@foo.bar = Bar.find(3)

Robert MannI wrote:

In your controller, do

@foo.bar_id = 3

or

@foo.bar = Bar.find(3)

Awesome, thanks! I tried it and it works great.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs