include_blank:false不适用于管理gem

时间:2018-09-27 05:27:29

标签: ruby-on-rails ruby select ruby-on-rails-5 administrate

我已经在_form.html.erb中生成了Fields::Belongs_to视图以自定义select元素,但是我似乎无法使include_blank: false正常工作。这是我的代码。我已经搜索了在选择块中使用include_blank的正确语法。

<div class="field-unit__label">
  <%= f.label field.permitted_attribute %>
</div>
<div class="field-unit__field">
  <%= f.select(field.permitted_attribute, include_blank: false) do %>
    <%= options_for_select(field.associated_resource_options, field.selected_option) %>
  <% end %>
</div>

edit:代码中include_blank的值

1 个答案:

答案 0 :(得分:0)

尝试一下:

<%= f.select(field.permitted_attribute, include_blank: "Choose...") do %>