Ben Wiseley
Ben Wiseley

Reputation: 547

Rails 3.1 - route redirect based on params?

I'm refactoring an app that has a bunch of urls coming like:

/plans/1?action=confirm&[email protected]

I'd like to redirect them, in routes.rb, to:

/plans/1/[email protected]

I've tried a number of approaches listed http://guides.rubyonrails.org/routing.html and http://www.engineyard.com/blog/2010/the-lowdown-on-routes-in-rails-3/ but am not having much luck.

I'm thinking that, because the action is after the ? I need to just do this in the controller. Is that the case?

Upvotes: 0

Views: 234

Answers (1)

Limbo Peng
Limbo Peng

Reputation: 2505

It would be easier to do in the controller.

Since redirect_to can take a Hash and turn it into a URL via url_for, I think this is what you want.

Upvotes: 2

Related Questions