Can redirect_to pass a hash parameter to it's target action?

Hi All,

I’m finding that redirect_to flattens hash parameters to a format that
doesn’t match the format a receiving action would expect. Does anyone
know if there is an elegant way to requestify the hash? (as this feature
is named in an integration test helper method).

For example, in an action I already have params[:search] as the {
:keyword => :requestify_hash } hash. Great. However, when I come to
redirect_to with my search param, url_for will output
search=keywordrequestify_hash. Booo!

What I was expecting (& hoping for), was that url_for would produce
search[keyword]=requestify_hash, so that web->action & action->action
behave the same way for receiving hashes, & the redirect will work

In case I’m way off base, I’ll explain what I’m trying to do.
Simplified, a search web page accepts input for a “keyword” field for
model “search”, & on hitting submit posts params including
search[keyword=requestify_hash] to a SearchesController. Using Restful
routing, the create method of SearchesController builds a Search object,
saves the search if the user requested it be saved, & then redirects to
a controller that can perform a search based on the search values.

A redirect_to suits, since I’m (potentially) creating new objects, &
want to avoid refresh issues. I want to avoid flash construct for the
same reason - refresh will lose the search hash. Redirect seemed ideal.
Having a model to represent searches is part of the system requirements
too, so I’m happy with the create search before running it notion.

Any ideas?

Thanks, Si

search[keyword=requestify_hash] to a SearchesController

That would be search[keyword]=requestify_hash actually.

I asked this question over at RailsWeenie, & it seems it’s a known issue
with Rails, with various patches submitted to Trac, & workaround helpers
can be found. You can pick up the trail here if you suffer from this

Arrgh!! Come on Apple, release those Merom MBPs!! temporary sig :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs