If you were using form_tag
, then radio_button_tag
would be a valid field type to use. And you could use the third parameter to indicate if the button is selected or not:
<%= radio_button_tag("q[location_cont]", "Kentucky", params[:q] && params[:q][:location_cont] == "Kentucky") %>
<%= label_tag "Kentucky" %></br></br>
<%= radio_button_tag("q[location_cont]", "Kansas", params[:q] && params[:q][:location_cont] == "Kansas") %>
<%= label_tag "Kansas" %></br></br>
Since you are using the Ransack search_form_for
, then you want to use radio_button
and I think you'd want something like this:
<%= f.radio_button(:location_cont, "Kentucky") %>
<%= f.label :location_cont, "Kentucky", value: "Kentucky" %></br></br>
<%= f.radio_button(:location_cont, "Kansas") %>
<%= f.label :location_cont, "Kansas", value: "Kansas" %></br></br>