Skip to content

Instantly share code, notes, and snippets.

@alekpopovic
Forked from ThomasHambach/routes.rb
Created April 4, 2016 20:53
Show Gist options
  • Select an option

  • Save alekpopovic/f861b5db8e193f9bfadbde8c7e7f9ce3 to your computer and use it in GitHub Desktop.

Select an option

Save alekpopovic/f861b5db8e193f9bfadbde8c7e7f9ce3 to your computer and use it in GitHub Desktop.
Rails redirect to default locale
Rails.application.routes.draw do
scope "/:locale" do
# blablabla..
end
root to: "welcome#index"
get '/:locale' => 'welcome#index', :as => 'locale_root'
end
class WelcomeController < ApplicationController
def index
if(params[:locale].nil?)
redirect_to locale_root_path, :status => :moved_permanently
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment