Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails: Redirecting all routes in a namespace to root

I'm looking to redirect all routes in a Rails namespace to the root path. Here's what I have so far. It works, but I wanted to see if I could get it into a single line:

namespace "old_namespace" do
  match "/", :to => redirect("/")
  match "*path", :to => redirect("/")
end
like image 757
zilla Avatar asked Mar 22 '23 19:03

zilla


1 Answers

Rails 3

namespace :old_namespace do
  match '(*any)' , to: redirect('/')
end

Rails 4

namespace :old_namespace do
  match '(*any)' , to: redirect('/'), via: [:get, :post]
end
like image 68
Muntasim Avatar answered Mar 31 '23 16:03

Muntasim