passing params to controller redirects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

passing params to controller redirects

fugee ohu
my index action is looking for params[:club][:genre_id]
after a club is successfully added or updated i wanna pass those (nested) params back to my index action so my filter will be set to the right genre_id but clubs_path(:genre_id => @genre_id) after setting @genre_id = params[:club][:genre_id] doesn't work the index page loads without a genre_id set

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8dc82eee-1301-4fbc-818b-2bd57984c8dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: passing params to controller redirects

Jason Fleetwood-Boldt
Did you try it without specifying the params?

Last I checked if you define a redirect(…) in your routes.rb file, the query params are automatically passed along to the redirected page. 

(*I'm on an older version of Rails, so if this changed in Rails recently then ask someone who has experience with more recent versions of Rails)


If that doesn't work maybe try

  get '/xyz', to: redirect {|path_params, req| "/abc#{'?' if req.params.any?}" + req.params.to_query}





On Jun 5, 2017, at 11:53 PM, fugee ohu <[hidden email]> wrote:

my index action is looking for params[:club][:genre_id]
after a club is successfully added or updated i wanna pass those (nested) params back to my index action so my filter will be set to the right genre_id but clubs_path(:genre_id => @genre_id) after setting @genre_id = params[:club][:genre_id] doesn't work the index page loads without a genre_id set

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8dc82eee-1301-4fbc-818b-2bd57984c8dc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

If you'd like to reply by encrypted email you can find my public key on jasonfleetwoodboldt.com (more about setting GPG: https://gpgtools.org

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2109DD4C-8F8A-4714-B987-1B5A83B5F80B%40datatravels.com.
For more options, visit https://groups.google.com/d/optout.
Loading...