表单中f.select上的“未定义”占位符

问题描述 投票:-1回答:1

我有一张表格

<%= form_for @user, url: contact_path do |form| %>
  <%= form.select(:email, User.all.map(&:email), {}, { class: 'my-form' }) %>
<% end %>

哪个效果很好,但在起始位置有占位符“Undefined”。我试图摆脱它

<%= form.select(:email, User.all.map(&:email), {placeholder: "Select email"}, { class: 'my-form' }) %>

要么

<%= form.select(:email, User.all.map(&:email), {prompt: "Select email"}, { class: 'my-form' }) %>

但仍然相同。有任何想法吗?

ruby-on-rails forms select
1个回答
0
投票
<%= form.select :email, options_for_select(User.all.map(&:email)), include_blank: "whatever your prompt says" , class: 'my-form' %>
© www.soinside.com 2019 - 2024. All rights reserved.