2012-06-08 35 views
0

我們的應用程序的一個特點是一定的「白色標籤」領域,但我想要做的是,如果用戶不啓用白標籤功能,當時的白標域只想着我們的根域(不需要保留子目錄)。如何根據數據庫字段轉發到不同的域?

因此,因爲它需要首先檢查數據庫(即@account.white_label?),然後THEN轉發,那麼檢查需要去哪裏以及我將使用哪個請求變量?

例如,我可能會說:

unless @account.white_label? 
    # check to see what current domain is 
    # if it's a "white label" domain and this account does not have that feature enabled, 
    # then redirect_to primary-domain.com 
ebd 

回答

1

你或許可以做這樣的事情在你的應用程序控制器:

class ApplicationController < ActionController::Base 

    before_filter :check_if_account_supports_white_label 

    def check_if_account_supports_white_label 
    domain = request.env['HTTP_HOST'] 
    unless Account.where(:domain => domain).first.supports_white_label? 
    redirect_to some_url 
    end 
    end 
end 
相關問題