Skip to content

Instantly share code, notes, and snippets.

@andreas-it-dev
Created October 23, 2016 10:30
Show Gist options
  • Save andreas-it-dev/4f827c2317af2e53cf6ee485e649bddb to your computer and use it in GitHub Desktop.
Save andreas-it-dev/4f827c2317af2e53cf6ee485e649bddb to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
force_ssl if: :ssl_configured?
before_action :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
def default_url_options
{ locale: I18n.locale == I18n.default_locale ? nil : I18n.locale }
end
def ssl_configured?
!Rails.env.development?
end
end
Rails.application.routes.draw do
scope "/:locale" do
resources :messages
resource :session
root 'static#home'
get 'about', to: 'static#about'
get 'imprint', to: 'static#imprint'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment