Reputation: 311
I'm trying to display a empty option for a select option, using it:
<%= form.select(:group_id, include_blank: true) do %>
<% @groups.each do |group| %>
<%= content_tag(:option, group.name, value: group.id) %>
<% end %>
<% end %>
This don't get any error, but not display too.
Upvotes: 0
Views: 238
Reputation:
Weird one, but I believe your include_blank
wasn't being passed in the right position. This is working for me.
<%= form.select(:group_id, nil, { include_blank: 'Please select' }) do %>
<% @groups.each do |group| %>
<%= content_tag(:option, group[:name], value: group[:id]) %>
<% end %>
<% end %>
Upvotes: 2