Q:

How do I set a default checked option with Rails collection_radio_buttons?

So I'm trying to set the first radio button as checked by default for a form. I can't figure out how to do it. I can get all of the inputs to have checked="checked" by adding checked: true or checked: 'checked' in the html options, as in the following: 
<%= f.collection_radio_buttons :category_id, @categories, :id, :name, {}, { checked: true } %>
<%= f.collection_radio_buttons :category_id, @categories, :id, :name, {}, { checked: 'checked' } %>

I've tried specifying checked: @category.first, as in the following:
<%= 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?

A:

I think you should marked id to be checked, so change to { checked: @category.first.id }

