2014-07-28 12:34:18 +03:00
|
|
|
class ApplicationController < ActionController::Base
|
2015-07-20 00:35:53 +03:00
|
|
|
include CurrentConferenceAssigning
|
2015-07-14 21:00:02 +03:00
|
|
|
|
2014-07-28 12:34:18 +03:00
|
|
|
# Prevent CSRF attacks by raising an exception.
|
|
|
|
# For APIs, you may want to use :null_session instead.
|
|
|
|
protect_from_forgery with: :exception
|
2019-04-28 02:15:39 +03:00
|
|
|
before_action :configure_permitted_parameters, if: :devise_controller?
|
2014-09-01 12:32:03 +03:00
|
|
|
before_action :set_locale
|
2015-08-15 03:43:41 +03:00
|
|
|
before_action :set_view_paths
|
|
|
|
|
|
|
|
# TODO: make this get the domain from the database
|
2019-04-28 21:10:54 +03:00
|
|
|
# layout Proc.new { |controller| controller.request.host }
|
|
|
|
layout "public/application"
|
2015-08-15 03:43:41 +03:00
|
|
|
|
2019-04-28 21:10:54 +03:00
|
|
|
def self.default_url_options(options = {})
|
2014-09-01 23:48:55 +03:00
|
|
|
if I18n.locale != I18n.default_locale
|
|
|
|
options.merge({locale: I18n.locale})
|
2014-09-01 12:56:33 +03:00
|
|
|
else
|
2014-09-01 23:48:55 +03:00
|
|
|
options
|
2014-09-01 12:56:33 +03:00
|
|
|
end
|
2014-09-01 12:32:03 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_locale
|
|
|
|
I18n.locale = params[:locale] || I18n.default_locale
|
2019-04-28 21:10:54 +03:00
|
|
|
if user_signed_in? && (current_user.language != I18n.locale)
|
2015-08-15 07:20:20 +03:00
|
|
|
current_user.update(language: I18n.locale)
|
|
|
|
end
|
2014-09-01 12:32:03 +03:00
|
|
|
end
|
2014-08-31 14:57:34 +03:00
|
|
|
|
2015-08-15 03:43:41 +03:00
|
|
|
def set_view_paths
|
|
|
|
# TODO: make this get the domain from the database
|
2019-04-28 21:10:54 +03:00
|
|
|
prepend_view_path "lib/initfest/views" if request.host =~ /openfest/
|
|
|
|
prepend_view_path "lib/initfest/views" if request.host =~ /example/
|
|
|
|
prepend_view_path "lib/initfest/views" if request.host =~ /127\.0\.0/
|
2015-08-15 03:43:41 +03:00
|
|
|
end
|
|
|
|
|
2014-08-31 14:57:34 +03:00
|
|
|
protected
|
|
|
|
|
|
|
|
def configure_permitted_parameters
|
2016-07-05 17:49:26 +03:00
|
|
|
devise_parameter_sanitizer.permit(:account_update, keys: [:language])
|
2014-08-31 14:57:34 +03:00
|
|
|
end
|
2014-07-28 12:34:18 +03:00
|
|
|
end
|