Given a radio button like so:
<%= radio_button_tag 'permission[role_id]', '2' %>
How can I make the radio buttons checked status condition. To only be checked if @permission.role_id.nil? or if @permission.role_id == 2?
I tried:
<%= radio_button_tag 'permission[role_id]', '2', @permission.role_id.nil? ? {:checked => true} : {:checked => false} %>
Thanks
The documentation for
radio_button_tagsays thatcheckedisn’t an options hash parameter, it’s just a normal one:So, you need to do this: