How to use radio button correctly in rails?
see label(object_name, method, content_or_options = nil, options = nil, &block)
<div class="field">
<%= f.label :autolyse %><br />
<%= f.label :autolyse, "Yes", :value => "true" %>
<%= f.radio_button :autolyse, true %>
<%= f.label :autolyse, "No", :value => "false" %>
<%= f.radio_button :autolyse, false, :checked => true %>
</div>
If you want to keep selected the option chosen by the user, you should validate the param, would be something like this:
<div class="field">
<%= f.label :autolyse %><br />
<%= f.label :autolyse, "Yes", :value => "true" %>
<%= f.radio_button :autolyse, true, !!params[:autolyse] %>
<%= f.label :autolyse, "No", :value => "false" %>
<%= f.radio_button :autolyse, false, !!params[:autolyse] %>
</div>
If you want to do it from the object properties you just replace the params variable for the object property:
<div class="field">
<%= f.label :autolyse %><br />
<%= f.label :autolyse, "Yes", :value => "true" %>
<%= f.radio_button :autolyse, true, [email protected] %>
<%= f.label :autolyse, "No", :value => "false" %>
<%= f.radio_button :autolyse, false, [email protected] %>
</div>