title: Rails Devise routing error - "No route matches" (controller=>"devise/sessions")
body: <p><strong>Edit 2: Looks like a quick temp fix for me was to add a forward slash "/" in front of the controller name in my link_to_unless_current and current_page methods from my view.
  e.g.</strong> </p>
  
  <pre><code>&lt;% active = current_page?(:controller =&gt; '/sites', :action =&gt; action) ? 'active' : '' %&gt;
        &lt;li class="&lt;%= active %&gt;"&gt;&lt;%= link_to_unless_current(anchor, { :controller =&gt; '/sites', :action =&gt; action }) %&gt;&lt;/li&gt;
  </code></pre>
  
  <p><strong>Here is more info on the problem I encountered in case anyone else runs into the same thing. <a href="https://github.com/plataformatec/devise/issues/471" rel="noreferrer">https://github.com/plataformatec/devise/issues/471</a></strong></p>
  
  <p>============================================================</p>
  
  <p>My devise path broke when I made my navigation (_header.html.erb) dynamic.  I'm hoping this is a simple fix, but really lost atm.  Every page on my site works, except when I go to /admin and then I get the routing error below:</p>
  
  <p>Here's the exact error I receive:</p>
  
  <pre><code>Started GET "/admin" for 75.13.95.55 at 2011-03-13 15:40:49 -0500
    Processing by AdminController#index as HTML
  Completed   in 2ms
  
  
  Started GET "/users/sign_in" for 75.13.95.55 at 2011-03-13 15:40:51 -0500
    Processing by Devise::SessionsController#new as HTML
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p0/gems/devise-1.1.5/app/views/devise/shared/_links.erb (1.9ms)
  Rendered layouts/_header.html.erb (37.0ms)
  Rendered /usr/local/rvm/gems/ruby-1.9.2-p0/gems/devise-1.1.5/app/views/devise/sessions/new.html.erb within layouts/application (57.5ms)
  Completed   in 91ms
  
  ActionView::Template::Error (No route matches {:action=&gt;"coupons", :controller=&gt;"devise/sessions"}):
      7: &lt;div id="navcontainer"&gt;
      8:   &lt;ul id="navlist"&gt;
      9:     &lt;% nav.each do |anchor, action| %&gt;
      10:       &lt;% active = current_page?(:action =&gt; action) ? 'active' : '' %&gt;
      11:       &lt;li class="&lt;%= active %&gt;"&gt;&lt;%= link_to_unless_current(anchor, { :action =&gt; action }) %&gt;&lt;/li&gt;
      12:     &lt;% end -%&gt;
      13:   &lt;/ul&gt;
    app/views/layouts/_header.html.erb:10:in `block in _app_views_layouts__header_html_erb__482084855_91994390_872614734'
    app/views/layouts/_header.html.erb:9:in `each'
    app/views/layouts/_header.html.erb:9:in `_app_views_layouts__header_html_erb__482084855_91994390_872614734'
    app/views/layouts/application.html.erb:17:in `_app_views_layouts_application_html_erb___293959382_92160660__194406143'
  </code></pre>
  
  <p>Here is the <code>config/routes.rb</code> file:</p>
  
  <pre><code>  devise_for :users
  
    match '/info' =&gt; 'sites#info', :as =&gt; :info
    match "/reviews" =&gt; 'sites#reviews', :as =&gt; :reviews
  
    resources :admin do
      collection do
        put 'moderate'
        get 'approved'
      end
    end
  
    root :to =&gt; 'sites#coupons'
  </code></pre>
  
  <p>Here's the <code>app/views/layouts/_header.html.erb</code> file:</p>
  
  <pre><code>&lt;% nav = { 'Coupons' =&gt; 'coupons', 'Reviews' =&gt; 'reviews', 'Info' =&gt; 'info' } %&gt;
  
  &lt;div id="navcontainer"&gt;
    &lt;ul id="navlist"&gt;
      &lt;% nav.each do |anchor, action| %&gt;
        &lt;% active = current_page?(:action =&gt; action) ? 'active' : '' %&gt;
        &lt;li class="&lt;%= active %&gt;"&gt;&lt;%= link_to_unless_current(anchor, { :action =&gt; action }) %&gt;&lt;/li&gt;
      &lt;% end -%&gt;
  </code></pre>
  
  <p>And here's the output of <code>rake routes</code>:</p>
  
  <pre><code>      new_user_session GET    /users/sign_in(.:format)           {:action=&gt;"new", :controller=&gt;"devise/sessions"}
            user_session POST   /users/sign_in(.:format)           {:action=&gt;"create", :controller=&gt;"devise/sessions"}
    destroy_user_session GET    /users/sign_out(.:format)          {:action=&gt;"destroy", :controller=&gt;"devise/sessions"}
                    info        /info(.:format)                    {:controller=&gt;"sites", :action=&gt;"info"}
                 reviews        /reviews(.:format)                 {:controller=&gt;"sites", :action=&gt;"reviews"}
  moderate_admin_index PUT    /admin/moderate(.:format)        {:action=&gt;"moderate", :controller=&gt;"admin"}
  approved_admin_index GET    /admin/approved(.:format)        {:action=&gt;"approved", :controller=&gt;"admin"}
           admin_index GET    /admin(.:format)                 {:action=&gt;"index", :controller=&gt;"admin"}
                         POST   /admin(.:format)                 {:action=&gt;"create", :controller=&gt;"admin"}
             new_admin GET    /admin/new(.:format)             {:action=&gt;"new", :controller=&gt;"admin"}
            edit_admin GET    /admin/:id/edit(.:format)        {:action=&gt;"edit", :controller=&gt;"admin"}
                 admin GET    /admin/:id(.:format)             {:action=&gt;"show", :controller=&gt;"admin"}
                         PUT    /admin/:id(.:format)             {:action=&gt;"update", :controller=&gt;"admin"}
                         DELETE /admin/:id(.:format)             {:action=&gt;"destroy", :controller=&gt;"admin"}
                    root        /(.:format)                        {:controller=&gt;"sites", :action=&gt;"coupons"}
  </code></pre>
  
  <p>Thanks for looking!</p>
  
  <p>Edit 1:
  When I tried the suggestion from @Dogbert, it didn't seem to make a difference unfortunately:</p>
  
  <pre><code>No route matches {:controller=&gt;"devise/sites", :action=&gt;"coupons"}
  Extracted source (around line #9):
  
  6: &lt;div id="navcontainer"&gt;
  7:   &lt;ul id="navlist"&gt;
  8:     &lt;% nav.each do |anchor, action| %&gt;
  9:       &lt;% active = current_page?(:controller =&gt; 'sites', :action =&gt; action) ? 'active' : '' %&gt;
  10:       &lt;li class="&lt;%= active %&gt;"&gt;&lt;%= link_to_unless_current(anchor, { :controller =&gt; 'sites', :action =&gt; action }) %&gt;&lt;/li&gt;
  11:     &lt;% end -%&gt;
  12:   &lt;/ul&gt;
  </code></pre>