title: Rails & Devise Mapping Path
body: <p>I'm receiving the following error when trying to go to <a href="http://app.mysite.dev/login" rel="nofollow">http://app.mysite.dev/login</a> -</p>
  
  <pre><code>Could not find devise mapping for path "/login".
  This may happen for two reasons:
  
  1) You forgot to wrap your route inside the scope block. For example:
  
    devise_scope :user do
      get "/some/route" =&gt; "some_devise_controller"
    end
  
  2) You are testing a Devise controller bypassing the router.
     If so, you can explicitly tell Devise which mapping to use:
  
     @request.env["devise.mapping"] = Devise.mappings[:user]
  </code></pre>
  
  <p>Now, here is the relevant bits of my routes.rb file:</p>
  
  <pre><code>namespace 'app', path: '', constraints: { subdomain: 'app' } do
      devise_for :users, :skip =&gt; [:registrations, :confirmations]
      devise_for :agents, :skip =&gt; :sessions
  
      devise_scope :users do
        get "login" =&gt; "users/sessions#new"
      end
      ...
  end
  </code></pre>
  
  <p>And the route generated by the <code>get "login"</code> line is as follows (from <code>rake routes</code>)</p>
  
  <pre><code>app_login GET    /login(.:format)     app/users/sessions#new {:subdomain=&gt;"app"}
  </code></pre>
  
  <p>I don't know if it matters, but I'm using STI for Users > Agents relationship.</p>
  
  <p>So, I already am defining the scope for devise, and I'm not testing, so any ideas what's going on?</p>