# Redirect\_to an uncertain hash

**URL:** <https://www.ruby-forum.com/t/redirect-to-an-uncertain-hash/90892>\
**Category:** Rails\
**Created:** [April 2, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/redirect-to-an-uncertain-hash/90892 "2007-04-02T20:08:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 2, 2007, 8:08pm UTC](https://www.ruby-forum.com/t/redirect-to-an-uncertain-hash/90892/1 "2007-04-02T20:08:05Z")

</div>

I am trying to deal with a redirection based upon what to do after a  
session has expired. I take the params hash and stuff it into a new  
session as part of the new login and then after login, I want to  
redirect to this hash as though they were params again…

Thus I start by setting  
session[:direct\_to] = @params

And after I login, I want to redirect based upon the values in  
session[:direct\_to]…

What I am trying to do is this but I keep getting syntax errors…

```
 redirect_to (session[:direct_to].each do |key, value|
   "#{key} => #{value}"
   end)

```

Of course there are values that are obvious such as  
session[:direct\_to][:controller]  
session[:direct\_to][:action]

but there are a lot of other params that may or may not be included so I  
am trying to abstract and recover them in my redirect\_to statement. Is  
there a way that I can do this?

–  
Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 2, 2007, 8:42pm UTC](https://www.ruby-forum.com/t/redirect-to-an-uncertain-hash/90892/2 "2007-04-02T20:42:09Z")

</div>

Hey,

rather than store the params hash in the session, why not just store  
the actual redirection url?

session[:direct\_to] = url\_for(params)

redirect\_to session[:direct\_to]

HTH  
Trevor

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 4, 2007, 12:48am UTC](https://www.ruby-forum.com/t/redirect-to-an-uncertain-hash/90892/3 "2007-04-04T00:48:25Z")

</div>

My - that was much simpler…thanks

Craig

On Mon, 2007-04-02 at 11:39 -0700, Trevor S. wrote:

> Trevor
> 
> > session[:direct\_to] = @params  
> > Of course there are values that are obvious such as
> 
> >

–  
Craig W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
