title: Devise with rails 4 authenticated root route not working
body: <h2>What I'm trying to do</h2>
  
  <p>I want to send a user to the registrations#new page if they aren't logged in.</p>
  
  <p>After you enter login info and click submit, I want you to be sent to the registrations#show page.</p>
  
  <h2>What is happening</h2>
  
  <p>It sends you to the registrations#new page when you're not logged in (correct so far).  But when you submit the login form, it sends errors out with a redirect loop.  The server's output is just this block repeated over and over:</p>
  
  <pre><code>Started GET "/" for 127.0.0.1 at 2013-09-25 02:31:59 -0400
  Processing by RegistrationsController#new as HTML
    User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 8 ORDER BY "users"."id" ASC LIMIT 1
  Redirected to http://lvh.me:3000/
  Filter chain halted as :require_no_authentication rendered or redirected
  Completed 302 Found in 2ms (ActiveRecord: 0.7ms)
  </code></pre>
  
  <p>I can't seem to figure it out.  It does log you in, as I can see that by manually navigating to a different page, but the <code>authenticated</code> root path is not working correctly.  I've tried a few different combinations in my routes file and can't seem to get it.  The code I'm using is based off of <a href="https://github.com/plataformatec/devise/issues/2393#issuecomment-17298414" rel="noreferrer">this thread</a></p>
  
  <h2>My code</h2>
  
  <p>In my application controller I have <code>before_filter :authenticate_user!</code></p>
  
  <p>My routes file:</p>
  
  <pre><code>devise_for :users, :controllers =&gt; {
    :registrations =&gt; "registrations"
  }
  
  devise_scope :user do
    root to: "registrations#new"
  end
  
  authenticated :user do
    root to: "registrations#show", :as =&gt; "profile"
  end
  
  unauthenticated do
    root to: "registrations#new", :as =&gt; "unauthenticated"
  end
  </code></pre>