【发布时间】:2015-02-28 00:01:49
【问题描述】:
您好,我正在我的应用的索引页面上创建一个 Devise 登录表单
Err: "nil:NilClass 的未定义方法 `router_name'"
<%= form_for("user", :url => new_user_session_path, :html => {:class => "cd-form"}) do |f| %>
<%- flash.each do |name, msg| -%>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
<%- end -%>
<span class="cd-error-message">Error message here!</span>
<div class="field">
<%= f.label :email, :class => 'image-replace cd-username' %><br />
<%= f.email_field :email, :class => 'full-width has-padding has-border', autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<% if @validatable %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, :class => 'full-width has-padding has-border', autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, :class => 'image-replace cd-password-2' %><br />
<%= f.password_field :password_confirmation, :class => 'full-width has-padding has-border', autocomplete: "off" %>
</div>
<%= render "users/shared/links" %>
<div class="actions">
<%= f.submit "Sign up", :class => 'full-width has-padding' %>
</div>
<% end %>
我没有使用 Mountable 引擎,也不打算使用。
按照其他指南,我也把它放在我的控制器中
def resource_name
:user
end
def resource
@resource ||= User.new
end
def devise_mapping
@devise_mapping ||= Devise.mappings[:user]
end
...
添加这个来抑制错误
...
def router_name
end
我认为不需要在 devise.rb 中配置它
【问题讨论】:
-
您找到解决此问题的方法了吗?我在视图规范中遇到了这个问题。
标签: ruby-on-rails-4 devise omniauth