2017-01-28 8 views
5

मैं अपने रेल ऐप के लिए डेविस का उपयोग करने का प्रयास करता हूं। मैं साइन अप और प्रवेश, लेकिन जब मैं अपने अन्य पृष्ठ पर जाएं "का निर्माण" मैं निम्न त्रुटि प्राप्त कर सकते हैं:सहायक उपकरण: अनुरोध पर्यावरण पर 'वार्डन :: प्रॉक्सी' उदाहरण नहीं मिला

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 

यहाँ मेरी दो आंशिक दृश्य वजह:

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.

यहाँ मेरी नियंत्रक है

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

डीबगिंग के बाद, मुझे पता चला कि समस्या मेरे "शो" नियंत्रक में इस लाइन से आ रही है: टेम्पलेट = होम कंट्रोलर.रेंडर ('लेआउट/_ टेम्पलेट')

आपकी मदद के लिए धन्यवाद।

+0

क्या यह तब होता है जब आप स्थानीय रूप से ऐप चलाते हैं, या जब आप अपना परीक्षण सूट चलाते हैं? –

उत्तर

9

इस SO answer के आधार पर आपको अपने नियंत्रक चश्मा में Devise::Test::ControllerHelpers मॉड्यूल शामिल करने की आवश्यकता है। अपने rails_helper में निम्नलिखित जोड़ें:

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

धन्यवाद, दुर्भाग्यवश यह काम नहीं करता है। – AlphaNico

+0

डीबगिंग के बाद, मुझे पता चला कि समस्या मेरे "शो" नियंत्रक में इस लाइन से आ रही है: टेम्पलेट = HomeController.render ('लेआउट/_ टेम्पलेट') – AlphaNico

संबंधित मुद्दे