当字段为空或用户已被邀请时,设计不可引发的引发错误

时间:2015-12-04 19:36:49

标签: forms ruby-on-rails-4 devise devise-invitable

我有专门设计的rails应用程序。如果我邀请尚未注册的用户,那么它的工作正常。如果我输入类似'fsafsdda'的内容,那么它会告诉我使用有效的表格。但是当我将该字段留空或邀请已有用户时,它会为<%= f.input field%>引发以下错误:在devise / invitations / new.html.erb中的行

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 %>

0 个答案:

没有答案