# Next page after log in

**URL:** <https://www.ruby-forum.com/t/next-page-after-log-in/174697>\
**Category:** Rails\
**Created:** [August 31, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/next-page-after-log-in/174697 "2009-08-31T16:09:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [August 31, 2009, 4:09pm UTC](https://www.ruby-forum.com/t/next-page-after-log-in/174697/1 "2009-08-31T16:09:42Z")

</div>

Hi,  
I have a best practice question:

In my web apps you have to log in to show a certain Item, but you can  
show the item’s list without log in.

Here are the steps:  
Items list page -\> click on certain Item -\> show “log in” page -\> show  
Item’s page

How can I do to store the “next\_page” information ?

whith flash[:next\_page] I had some problem (because of reload current  
page)

Any suggest ?

thank you,  
Alessandro

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [September 2, 2009, 8:04am UTC](https://www.ruby-forum.com/t/next-page-after-log-in/174697/2 "2009-09-02T08:04:04Z")

</div>

If you’re using restful\_authentication plugin, check out the method  
called redirect\_back\_or\_default. Even otherwise, I think thats what  
you want. Its a simple short method, try getting your hands on it.

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [September 2, 2009, 9:21am UTC](https://www.ruby-forum.com/t/next-page-after-log-in/174697/3 "2009-09-02T09:21:54Z")

</div>

Hi,

You can store this information in the session, and then in your login  
action  
you should check if session[:next\_page] is present, redirect user to  
that  
page; else to normal home page.

–  
Abhinav  
[http://twitter.com/abhinav](http://twitter.com/abhinav)

---

<div class="post-metadata">

**Author:** ![spitfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a5b964/32.png) [@spitfire](https://www.ruby-forum.com/u/spitfire)\
**Post date:** [September 2, 2009, 3:15pm UTC](https://www.ruby-forum.com/t/next-page-after-log-in/174697/4 "2009-09-02T15:15:07Z")

</div>

Ram wrote:

> If you’re using restful\_authentication plugin, check out the method  
> called redirect\_back\_or\_default. Even otherwise, I think thats what  
> you want. Its a simple short method, try getting your hands on it.

Hi,  
I am using authlogic as authentication plugin,  
I don’t know if in authlogic there is some method similar to  
redirect\_back\_or\_default (I have to check out. Anyone know it ?),  
if I didn’t find it, I will use “session[:next\_page]” (as Abhinav  
suggested).

thank you,  
Alessandro

[http://twitter.com/alexdesi](http://twitter.com/alexdesi)
