# Nested params and redirect\_to

**URL:** <https://www.ruby-forum.com/t/nested-params-and-redirect-to/110297>\
**Category:** Rails\
**Created:** [July 25, 2007, 12:26am UTC](https://www.ruby-forum.com/t/nested-params-and-redirect-to/110297 "2007-07-25T00:26:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [July 25, 2007, 12:26am UTC](https://www.ruby-forum.com/t/nested-params-and-redirect-to/110297/1 "2007-07-25T00:26:18Z")

</div>

I have a simple client search screen that posts the following params:

Parameters: {“search”=\>“Search”, “action”=\>“list”,  
“client\_search”=\>{“first\_name”=\>“jane”, last\_name"=\>“smith”},  
“controller”=\>“client”}

This works fine. However I want to redirect to the same destination to  
do the search without the intervening screen.  
I have used the code:  
redirect\_to :action=\>“list”, :client\_search=\>{:first\_name =\>  
“jane”,:last\_name=\>“smith”}

This does not work… the parameters appear as:  
Parameters: {“action”=\>“list”,  
“client\_search”=\>“last\_namesmithfirst\_namejane”,  
“controller”=\>“client”}

ie it is not nesting the “client\_search” hash and I get the following  
error when trying to update the attributes on the client\_search table  
using these params:  
NoMethodError (undefined method `stringify_keys!' for "last_namesmithfirst_namejane":String): E:/RailsApps/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/base.rb:1668:in`attributes=’  
E:/RailsApps/ruby/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/  
active\_record/base.rb:1591:in `update\_attributes’

Can anyone tell me what I am doing wrong and how to get around the  
problem.

Thanks  
George

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [July 25, 2007, 12:57am UTC](https://www.ruby-forum.com/t/nested-params-and-redirect-to/110297/2 "2007-07-25T00:57:49Z")

</div>

try out the flash:

flash[:client\_search] = params[:client\_search]

they should then be available in the flash to the next controller  
instance invoked by the redirect.

good luck  
Tim

---

<div class="post-metadata">

**Author:** ![giorgio](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/cab0a1/32.png) [@giorgio](https://www.ruby-forum.com/u/giorgio)\
**Post date:** [July 25, 2007, 1:14am UTC](https://www.ruby-forum.com/t/nested-params-and-redirect-to/110297/3 "2007-07-25T01:14:23Z")

</div>

If I do that then the other action that is being redirected to will  
have to read from flash sometimes and sometimes just use params. I  
really want to redirect to it as if I was coming from the search  
screen…

G.
