You can do this: Pass in checked to check the item
<%= radio_button_tag 'theme', theme, checked: @theme.FIELD_NAME == 'design' %>
See here for details http://apidock.com/rails/ActionView/Helpers/FormTagHelper/radio_button_tag
Answering your comment:
Ahmm I dont understand? :( So <%= radio_button_tag 'theme', theme %>
becomes <%= radio_button_tag 'theme', theme, checked:
@theme.FIELD_NAME == 'design' %> ?? But this throws an error? I just
want the first radio button element to be selected by default –
FIELD_NAME is the name of the column on your Model. To just check the first item you can try this: Just add the checked: true keyword
<%= radio_button_tag 'theme', theme, @theme == theme, checked: true %>
Ok so you need to do the following:
<% [ 'Design 1', 'Design 2', 'Design 3', 'Design 4', 'Design 5' ].each_with_index do |theme, i| %>
<% if i == 0 %>
<br><%= radio_button_tag 'theme', theme, @theme == theme, checked: true %>
<% else %>
<br><%= radio_button_tag 'theme', theme, @theme == theme %>
<% end %>
<%= label_tag "theme_#{theme}", theme.humanize %>
<% end %>