contactorama/app/controllers/application_controller.rb
2012-04-04 22:24:44 +02:00

21 lines
711 B
Ruby

class ApplicationController < ActionController::Base
protect_from_forgery
layout :layout_by_resource
# Setup the locale based on the domain name used to access the website
before_filter :set_locale
private
# This sets the locale based on hostname. (see config/initializers/locales.rb)
# Can be overridden with locale parameter, i.e. http://localhost:3000/?locale=de
def set_locale
this_domain_ext = request.host.split('.').last
I18n.locale = params[:locale] || DEFAULT_LANGUAGE_BY_DOMAIN[this_domain_ext] || 'en'
end
# Selects a layout different from layouts/application for some special pages.
def layout_by_resource
devise_controller? ? 'login' : 'application'
end
end