Created
June 30, 2016 21:57
-
-
Save pecha7x/9759a5d3402f39d3e522855e46e51624 to your computer and use it in GitHub Desktop.
- process a request based on subdomain 1. locale 2. view, images 3. some model level code calling for only harbin and cannon 4. load subdomain specific css/js file
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 ApplicationController < ActionController::Base | |
around_filter :scope_current_tenant | |
after_filter :set_locale | |
layout :tenant_layout | |
prepend_view_path "app/views/#{current_tenant}" | |
def current_tenant | |
@current_tenant ||= Tenant.find_by_subdomain(request.subdomain) | |
end | |
helper_method :current_tenant | |
private | |
def scope_current_tenant(&block) | |
if current_tenant.nil? | |
redirect_to main_index_path | |
else | |
redirect_to main_index_path(current_tenant.id) | |
current_tenant.scope_schema("public", &block) #it ensure model level code calling for only harbin and cannon | |
end | |
end | |
def set_locale | |
I18n.locale = current_tenant.locale.to_sym | |
end | |
def tenant_layout | |
#load specific js/css for each layout | |
current_tenant.layout_name | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment