So, I'm trying to set the first radio button, by default, set for the form. I canโt figure out how to do this. I can get all the input to have checked="checked" by adding check: true or checked: "checked" in the html parameters as shown below:
<%= f.collection_radio_buttons :category_id, @categories, :id, :name, {}, { checked: true } %> <%= f.collection_radio_buttons :category_id, @categories, :id, :name, {}, { checked: 'checked' } %>
I tried to specify check checked: @category.first , as shown below:
<%= f.collection_radio_buttons :category_id, @categories, :id, :name, {}, { checked: @category.first } %>
But that doesn't work either. None of the inputs are checked.
Any ideas?
ruby-on-rails
Adamb
source share