Simon Nicholls
2006-Sep-25 13:49 UTC
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 nicely. 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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Simon Nicholls
2006-Sep-25 15:11 UTC
Re: Can redirect_to pass a hash parameter to it''s target act
> search[keyword=requestify_hash] to a SearchesControllerThat 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 too: http://rails.techno-weenie.net/question/2006/7/31/creating-a-url-with-params-from-a-hash Arrgh!! Come on Apple, release those Merom MBPs!! temporary sig :-) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---