我有带有可邀请设计的 Rails 应用程序。如果我邀请尚未注册的用户,那么它工作正常。如果我输入“fsafsdda”之类的内容,它会告诉我使用有效的形式。但是,当我将该字段留空或邀请现有用户时,它会为 devise/invitations/new.html.erb 中的 <%= f.input field %> 行引发以下错误
undefined method `input' for <ActionView::Helpers::FormBuilder:0x007fd644108d68>
我错过了什么?
html.erb
<div class="invite">
<%= simple_form_for(User.new, url: user_invitation_path) do |f| %>
<div class="form-group">
<div class="input-group input-group">
<%= f.input :email, placeholder: 'Invite via email', label: false, class: 'form-control' %>
<span class="input-group-btn">
<%= content_tag :button, type: :submit, class: 'btn btn-success' do %>
<span class="glyphicon glyphicon-envelope"></span>
<%end%>
</span>
</div>
</div>
<% end %>
</div>
默认设计/邀请/new.html.erb
<h2><%= t "devise.invitations.new.header" %></h2>
<%= form_for resource, as: resource_name, url: invitation_path(resource_name), html: { method: :post} do |f| %>
<%= devise_error_messages! %>
<div class="field form-group">
<% resource.class.invite_key_fields.each do |field| -%>
<%= f.input field %> ##ERROR THROWN HERE
<% end -%>
</div>
<div class="actions">
<%= f.button :submit, t("devise.invitations.new.submit_button"), class: "btn btn-primary" %>
</div>
<% end %>