2017-01-28 13 views
5

私のRailsアプリケーションにDeviseを使用しようとしました。私はサインアップすると、ログインが、私は私の他のページに移動するとき、私は次のエラーを取得する「構築」することができます:ここではHelper Devise:リクエスト環境で `Warden :: Proxy`インスタンスを見つけることができませんでした

Devise::MissingWarden in Home#show Devise could not find the Warden::Proxy instance on your request environment. Make sure that your application is loading Devise and Warden as expected and that the Warden::Manager middleware is present in your middleware stack. If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using the Devise::Test::ControllerHelpers module to inject the request.env['warden'] object for you.

は私のコントローラです:

:ここ

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 

は私の二つの部分のビューをREA

<!-- 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')

ありがとうございました。

+0

ローカルでアプリケーションを実行するとき、またはテストスイートを実行するときにこれが起こりますか? –

答えて

9

このSO answerに基づいて、コントローラの仕様にDevise::Test::ControllerHelpersモジュールを含める必要があります。 rails_helperに次を追加してください:

RSpec.configure do |config| 
    config.include Devise::Test::ControllerHelpers, type: :controller 
end 
+0

ありがとう、残念ながらそれは動作しません。 – AlphaNico

+0

デバッグ後、私は "show"コントローラのこの行から問題が発生していることを知りました:template = HomeController.render( 'layouts/_template') – AlphaNico

関連する問題