Created
February 9, 2015 11:01
-
-
Save ThomasHambach/eb140f67e9b778c39eba to your computer and use it in GitHub Desktop.
Rails redirect to default locale
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.application.routes.draw do | |
scope "/:locale" do | |
# blablabla.. | |
end | |
root to: "welcome#index" | |
get '/:locale' => 'welcome#index', :as => 'locale_root' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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