lib/alchemy/controller_actions.rb in alchemy_cms-3.2.0.beta vs lib/alchemy/controller_actions.rb in alchemy_cms-3.2.0.rc1
- old
+ new
@@ -44,11 +44,20 @@
end
# Returns the current site.
#
def current_alchemy_site
- @current_alchemy_site ||= Site.find_for_host(request.host)
+ @current_alchemy_site ||= begin
+ site_id = params[:site_id] || session[:site_id]
+ if site_id.nil?
+ session.delete :site_id
+ Site.find_for_host(request.host)
+ else
+ session[:site_id] = site_id
+ Site.find(site_id)
+ end
+ end
end
# Ensures usage of Alchemy's permissions class.
#
# Merges existing CanCan abilities from host Rails app with Alchemy's own CanCan abilities.
@@ -93,12 +102,12 @@
end
store_current_alchemy_language(@language)
end
def load_alchemy_language_from_params
- if params[:lang].present?
- Language.find_by_code(params[:lang])
+ if params[:locale].present?
+ Language.find_by_code(params[:locale])
end
end
def load_alchemy_language_from_session
if session[:alchemy_language_id].present?
@@ -123,8 +132,7 @@
if language && language.id
session[:alchemy_language_id] = language.id
Language.current = language
end
end
-
end
end