Forum: Ruby on Rails Passing more than one parameters to redirect_to

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
195b026049dbc00fe8096598f18a5312?d=identicon&s=25 Selva Raj (selva_rails)
on 2008-10-24 03:53
Hi,

I am getting some error which I am clue less. I try to pass more than
one parameter with redirect_to, For example,

My params are...
search => {"name"=>"", "bus_group"=>"1", "region"=>"", "unapproved"=>"",
"tech_owner"=>""}

And I try to give.

redirect_to params[:search].merge! (:action => 'list')

After executing this if I see in log file its showing like

{"bus_group"=>nil, "name"=>"", "amp;region"=>nil, "amp;tech_owner"=>nil,
"region"=>"", "amp"=>"", "action"=>"list", "amp;name"=>nil,
"controller"=>"tech_projects", "amp;unapproved"=>nil, "unapproved"=>"",
"tech_owner"=>""}

I am confused why this "amp;" generally "&" will be parameter separator
but one parameter itself called "amp;".also every params are available
twice.
195b026049dbc00fe8096598f18a5312?d=identicon&s=25 Selva Raj (selva_rails)
on 2008-10-24 04:45
Is there any other solution to solve this situation??

Selva Raj wrote:
> Hi,
>

> My params are...
> search => {"name"=>"", "bus_group"=>"1", "region"=>"", "unapproved"=>"",
> "tech_owner"=>""}

> redirect_to params[:search].merge! (:action => 'list')

> {"bus_group"=>nil, "name"=>"", "amp;region"=>nil, "amp;tech_owner"=>nil,
> "region"=>"", "amp"=>"", "action"=>"list", "amp;name"=>nil,
> "controller"=>"tech_projects", "amp;unapproved"=>nil, "unapproved"=>"",
> "tech_owner"=>""}
>
C64e63b70be7dfed8b0742540b8b27e5?d=identicon&s=25 Mark Reginald James (Guest)
on 2008-10-24 17:04
(Received via mailing list)
Selva Raj wrote:
>
> but one parameter itself called "amp;".also every params are available
> twice.

Mmmm, try redirect_to {:action => :list}.update(params[:search])

--
Rails Wheels - Find Plugins, List & Sell Plugins -
http://railswheels.com
195b026049dbc00fe8096598f18a5312?d=identicon&s=25 Selva Raj (selva_rails)
on 2008-10-27 08:29
Thanks James,

But its not working, I am using redirect_to in rjs.

If I use "update", that RJS itself not working.

Regards
Selvaraj.S

Mark Reginald James wrote:
> Selva Raj wrote:
>>
>> but one parameter itself called "amp;".also every params are available
>> twice.
>
> Mmmm, try redirect_to {:action => :list}.update(params[:search])
>
> --
> Rails Wheels - Find Plugins, List & Sell Plugins -
> http://railswheels.com
A1247f73598357f06388e863c41aa624?d=identicon&s=25 Elias Orozco (elioncho)
on 2008-10-27 08:43
(Received via mailing list)
I use something like this to pass extra params on restful routes.
Notice the extra params inside the {}.

redirect_to user_path(@user, {:params1 => 1, :params2 => 2})

Hope it helps,

Elioncho

On Oct 27, 2:29 am, Selva Raj <rails-mailing-l...@andreas-s.net>
Dd9ab512706dd6cb1de818a658566ba2?d=identicon&s=25 nas (Guest)
on 2008-10-27 11:49
(Received via mailing list)
Whenever you pass more than one parameter in an rjs using redirect_to
then it always adds &amp; in the beginning of parameters after the
first one. I had this issue as well in the past and after spending
hours to fix it, I ended up using only redirect_to instead of
redirect_to from rjs (basically I couldn't sort it out).

My guess is that, &amp; is added by prototype somehow.
D378a96237ecbd3dc2a3a5e1708374c7?d=identicon&s=25 Gamal Zur aue (gamal99)
on 2009-11-13 11:09
nas wrote:
> Whenever you pass more than one parameter in an rjs using redirect_to
> then it always adds &amp; in the beginning of parameters after the
> first one. I had this issue as well in the past and after spending
> hours to fix it, I ended up using only redirect_to instead of
> redirect_to from rjs (basically I couldn't sort it out).
>
> My guess is that, &amp; is added by prototype somehow.

Try using:
 :escape => false

as an additinal Parameter.
This topic is locked and can not be replied to.