title: Devise ignore my custom strategy
body: <p>I want to create a custom auth strategy for accessing the API. I followed the example code at <a href="https://stackoverflow.com/questions/3503827/devise-ignoring-custom-strategy">Devise ignoring custom strategy</a>.</p>
  
  <p>The problem is that the valid? method in my Api strategy is never run (based on trying to pry in it).</p>
  
  <p>My code:</p>
  
  <pre><code>module Devise
    module Strategies
      class Api &lt; Devise::Strategies::Base
        def valid?
          binding.pry
          params[:request_source] == 'api'
        end
  
        def authenticate!
          #do stuff here
  
          if user
            success!(user)
          else
            warden.custom_failure!
            render :json=&gt; {:success=&gt;false, :message=&gt;"Error with your login or password"}, :status=&gt;401
          end
        end
      end
  
      Warden::Strategies.add(:api, Devise::Strategies::Api)
  
    end
  end
  </code></pre>
  
  <p>and in the devise initializer:</p>
  
  <pre><code>config.warden do |manager|
    manager.default_strategies.unshift :api
  end
  </code></pre>
  
  <p>What ever I do, it seems like Devise always use its default strategy. AFAIK, this should be enough...</p>
  
  <p>-------EDIT--------</p>
  
  <p>I require the strategy like this at the very top of my devise initializer:</p>
  
  <pre><code>require Rails.root.join('app/devise/strategies/api')
  </code></pre>
  
  <p>I know the strategy is loaded at boot time since if I put a pry call inside the class, it will start a pry session. But the Pry calls inside the methods are never run. :-S</p>