Tom Rossi
Tom Rossi

Reputation: 12066

How to redirect with a 301 or 302 in the routes.rb

How can you redirect using a 302 from within the routes.rb file?

Upvotes: 44

Views: 15234

Answers (1)

Tom Rossi
Tom Rossi

Reputation: 12066

You can pass in the status to the redirect in the route statement. For example, to do a 302 redirect:

In the routes.rb

get '/old/path', to: redirect('/new/path', status: 302)

I hope this helps someone else!

Upvotes: 88

Related Questions