-
-
Save alekpopovic/f861b5db8e193f9bfadbde8c7e7f9ce3 to your computer and use it in GitHub Desktop.
Rails redirect to default locale
This file contains hidden or 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 hidden or 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