问题描述
我尝试将Devise用于我的Rails应用程序。我可以注册并登录,但是当我转到其他页面 build时,出现以下错误:
I try to use Devise for my Rails app. I can sign up and login but when I go to my other page "build" I get the following error:
这是我的控制器:
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
private
# Overwriting the sign_out redirect path method
def after_sign_out_path_for(resource_or_scope)
build_path
end
end
这里有我的两个局部视图:
Here rea my two partial views:
<!-- views/devise/menu/_login_items.html.erb -->
<% if user_signed_in? %>
<li>
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
</li>
<% else %>
<li>
<%= link_to('Login', new_user_session_path) %>
</li>
<% end %>
和
<!-- views/devise/menu/_registration_items.html.erb -->
<% if user_signed_in? %>
<li>
<%= link_to('Edit registration', edit_user_registration_path) %>
</li>
<% else %>
<li>
<%= link_to('Register', new_user_registration_path) %>
</li>
<% end %>
调试之后,我发现问题出在我的 show控制器的这一行: template = HomeController.render('layouts / _template')
After debugging, I figured out that the problem is coming from this line in my "show" controller: template = HomeController.render('layouts/_template')
感谢您的帮助。
推荐答案
基于此,您需要添加 Devise ::在控制器规格中测试Test :: ControllerHelpers
模块。将以下内容添加到rails_helper中:
Based on this SO answer you need to include the Devise::Test::ControllerHelpers
module in your controller specs. Add the following to your rails_helper:
RSpec.configure do |config|
config.include Devise::Test::ControllerHelpers, type: :controller
end
这篇关于Helper Devise:在请求环境中找不到`Warden :: Proxy`实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!