# Why is user/new redirecting to sessions/new and then looping?

**URL:** <https://www.ruby-forum.com/t/why-is-user-new-redirecting-to-sessions-new-and-then-looping/160666>\
**Category:** Rails\
**Created:** [February 18, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/why-is-user-new-redirecting-to-sessions-new-and-then-looping/160666 "2009-02-18T16:51:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [February 18, 2009, 4:51pm UTC](https://www.ruby-forum.com/t/why-is-user-new-redirecting-to-sessions-new-and-then-looping/160666/1 "2009-02-18T16:51:39Z")

</div>

I’ve started out my new rails app by setting up users and sessions by  
following the example in the FlexibleRails book. This uses the  
restful\_authentication plugin. It then generates users sessions and  
sets up basic routes like

map.resources :users  
map.resource :session

map.signup ‘/signup’, :controller =\> ‘users’, :action =\> ‘new’  
map.login ‘/login’, :controller =\> ‘sessions’, :action =\> ‘new’  
map.logout ‘/logout’, :controller =\> ‘sessions’, :action =\>  
‘destroy’

After setting all that up I tested it manually and ran rake to run the  
tests, and everything worked fine.

Then I started generating my scaffolds and models, and probably waited  
too long to run tests again. Now when I run rake, I get a bunch of  
errors in UserController and SessionController. In addition, when I  
go to localhost:3000/signup, which is supposed to take me to the  
generated new user screen, I get an infinite redirect to session/new.  
Here’s the log for the signup page:

Processing UsersController#new (for 127.0.0.1 at 2009-02-18 10:07:57)  
[GET]  
Session ID:  
BAh7BzoOcmV0dXJuX3RvIhEvc2Vzc2lvbi9uZXciCmZsYXNoSUM6J0FjdGlv%0AbkN  
vbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7AAY6CkB1c2VkewA%3D–  
a1d287f3622f9cc0c08e2f5  
7691a42ef83a3e811  
Parameters: {“action”=\>“new”, “controller”=\>“users”}  
e$B"+e(B[4;36;1mSQL (0.000000)e$B"+e(B[0m e$B"+e(B[0;1mSET  
SQL\_AUTO\_IS\_NULL=0e$B"+e(B[0m  
Redirected to [http://localhost:3000/session/new](http://localhost:3000/session/new)  
Completed in 0.00010 (10000 reqs/sec) | DB: 0.00000 (0%) | 302 Found  
[[http://localhost/signup](http://localhost/signup)]

Processing SessionsController#new (for 127.0.0.1 at 2009-02-18  
10:07:57) [GET]  
Session ID:  
BAh7BzoOcmV0dXJuX3RvIgwvc2lnbnVwIgpmbGFzaElDOidBY3Rpb25Db250%0Acm9  
sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewAGOgpAdXNlZHsA–  
c95428aa8926994b68c56d23ff54ca430  
cd6263a  
Parameters: {“action”=\>“new”, “controller”=\>“sessions”}  
Redirected to [http://localhost:3000/session/new](http://localhost:3000/session/new)  
Completed in 0.00010 (10000 reqs/sec) | DB: 0.00000 (0%) | 302 Found  
[[http://localhost/session/new](http://localhost/session/new)]

I’m not sure what that ‘SET SQL\_AUTO\_IS\_NULL’ is or if it’s normal or  
not. I googled it but didn’t find anything relevant.

The UsersController class only defines an empty method for new, so  
it’s suppose to show the new.rhtml, right? Why is it redirecting to  
the session controller?

---

<div class="post-metadata">

**Author:** ![brian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/97f17d/32.png) [@brian](https://www.ruby-forum.com/u/brian)\
**Post date:** [February 18, 2009, 11:11pm UTC](https://www.ruby-forum.com/t/why-is-user-new-redirecting-to-sessions-new-and-then-looping/160666/2 "2009-02-18T23:11:26Z")

</div>

Is there maybe a before\_filter to redirect to the login page when not  
logged in?
