# Redirect\_to that doesn't

**URL:** <https://www.ruby-forum.com/t/redirect-to-that-doesnt/185483>\
**Category:** Rails\
**Created:** [March 21, 2010, 9:34am UTC](https://www.ruby-forum.com/t/redirect-to-that-doesnt/185483 "2010-03-21T09:34:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeffrey\_LSTaylor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee7513/32.png) [@Jeffrey\_LSTaylor](https://www.ruby-forum.com/u/Jeffrey_LSTaylor)\
**Post date:** [March 21, 2010, 9:34am UTC](https://www.ruby-forum.com/t/redirect-to-that-doesnt/185483/1 "2010-03-21T09:34:57Z")

</div>

I have some code that works when logged\_in but not when not logged\_in.  
The  
switch\_theme action just changes the variable controlling the CSS  
stylesheet  
and does a ‘redirect\_to :back’. But no other action is called. The log  
looks  
like below. Ring any bells?

TIA,  
Jeffrey

Non-working:

Processing ApplicationController#switch\_theme (for 127.0.0.1 at  
2010-03-21 03:20:53) [GET]  
Parameters: {“action”=\>“switch\_theme”, “controller”=\>“application”}  
User Columns (1.6ms) SHOW FIELDS FROM `users`  
User Load (0.6ms) SELECT \* FROM `users` WHERE (`users`.`login` =  
‘Jeff’) LIMIT 1  
Redirected to [http://127.0.0.1:3000/items](http://127.0.0.1:3000/items)  
Completed in 31ms (DB: 17) | 302 Found [[http://127.0.0.1/switch\_theme](http://127.0.0.1/switch_theme)]

==========================================================================  
Working:

Processing ApplicationController#switch\_theme (for 127.0.0.1 at  
2010-03-21 03:31:17) [GET]  
Parameters: {“action”=\>“switch\_theme”, “controller”=\>“application”}  
User Columns (1.8ms) SHOW FIELDS FROM `users`  
User Load (0.6ms) SELECT \* FROM `users` WHERE (`users`.`login` =  
‘Jeff’) LIMIT 1  
User Load (0.5ms) SELECT \* FROM `users` WHERE (`users`.`id` = ‘1’)  
LIMIT 1  
SQL (0.1ms) BEGIN  
User Update (0.5ms) UPDATE `users` SET `updated_at` = ‘2010-03-21  
08:31:17’, `perishable_token` = ‘PE2oMoDx2BDp58azOFPx’,  
`last_request_at` = ‘2010-03-21 08:31:17’ WHERE `id` = 1  
SQL (10195.9ms) COMMIT  
SQL (0.3ms) BEGIN  
User Update (0.7ms) UPDATE `users` SET `updated_at` = ‘2010-03-21  
08:31:27’, `perishable_token` = ‘9gNKIRTV7FdKYa-To9XQ’, `theme` = 1  
WHERE `id` = 1  
SQL (829.0ms) COMMIT  
Redirected to [http://127.0.0.1:3000/articles](http://127.0.0.1:3000/articles)  
Completed in 11108ms (DB: 11042) | 302 Found  
[[http://127.0.0.1/switch\_theme](http://127.0.0.1/switch_theme)]  
SQL (5.9ms) SET NAMES ‘utf8’  
SQL (0.1ms) SET SQL\_AUTO\_IS\_NULL=0

Processing ArticlesController#index (for 127.0.0.1 at 2010-03-21  
03:31:28) [GET]  
Parameters: {“action”=\>“index”, “controller”=\>“articles”}  
User Columns (1.7ms) SHOW FIELDS FROM `users`  
User Load (0.5ms) SELECT \* FROM `users` WHERE (`users`.`login` =  
‘Jeff’) LIMIT 1  
User Load (0.5ms) SELECT \* FROM `users` WHERE (`users`.`id` = ‘1’)  
LIMIT 1  
SQL (0.3ms) BEGIN  
User Update (0.4ms) UPDATE `users` SET `updated_at` = ‘2010-03-21  
08:31:28’, `perishable_token` = ‘QFCwPhX4OCZ4EmLj7Q6f’,  
`last_request_at` = ‘2010-03-21 08:31:28’ WHERE `id` = 1  
SQL (52.3ms) COMMIT  
Feed Load (0.8ms)  
…

---

<div class="post-metadata">

**Author:** ![Jeffrey\_LSTaylor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ee7513/32.png) [@Jeffrey\_LSTaylor](https://www.ruby-forum.com/u/Jeffrey_LSTaylor)\
**Post date:** [March 22, 2010, 8:31am UTC](https://www.ruby-forum.com/t/redirect-to-that-doesnt/185483/2 "2010-03-22T08:31:48Z")

</div>

Any chance of seeing the code instead 🙂

Cheers  
Luke
