# Checking redirection or the previous action

**URL:** <https://www.ruby-forum.com/t/checking-redirection-or-the-previous-action/91467>\
**Category:** Rails\
**Created:** [April 9, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/checking-redirection-or-the-previous-action/91467 "2007-04-09T16:05:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [April 9, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/checking-redirection-or-the-previous-action/91467/1 "2007-04-09T16:05:27Z")

</div>

Hi you all,  
I have two actions in my controller in this way:

def list\_by\_bubble  
Bla bla bla  
redirect\_to(:action =\> ‘list\_by\_filter’)  
end  
def list\_by\_filter  
#To display always  
Bla bla bla  
#To display just the rest of the times  
Bla bla bla  
end

That is, the first time, user will go to list\_by\_bubble, and it  
redirects to list\_by\_filter. In this method, I just one to display the  
“display always stuff”, not the other. The other stuff will be executed  
the rest of the times, but not this first time.  
So, my question is, how can I get in “list\_by\_filter” if the previous  
action was “list\_by\_bubble” or not? Or if I have reached there by a  
redirection?

Thanks 😃

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [April 10, 2007, 10:44am UTC](https://www.ruby-forum.com/t/checking-redirection-or-the-previous-action/91467/2 "2007-04-10T10:44:51Z")

</div>

Damaris F. wrote:

> #To display just the rest of the times
> 
> Thanks 😃

Not sure I understand what you’re trying to do. It sounds like you might  
want to have a single list action, with a default set of parameters:

def list  
if #first time visited here  
foo  
else  
bar  
end  
end

The condition could be set a number of ways – in the session, with a  
cookie, or via a flag in the user’s record.

Hope this helps  
Chris

* * *

[http://www.autopendium.co.uk](http://www.autopendium.co.uk)  
stuff about old cars

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [April 10, 2007, 12:37pm UTC](https://www.ruby-forum.com/t/checking-redirection-or-the-previous-action/91467/3 "2007-04-10T12:37:14Z")

</div>

Ok, I will do that.  
I thought there was any rails object to ask for that (in the request or  
something)

Thanks 😃
