2012-03-21 43 views
2

內,當我嘗試使用主動管理一個項目。該項目還使用另一個gem來分隔不同的租戶,以及用於正常驗證的has_secure_password。如何跳過application_controller只調用某個命名空間(ActiveAdmin)

當用戶進入到活動管理員( - 管理員只是一個不同的命名空間),我有兩跳過這些過濾器的問題。

class ApplicationController < ActionController::Base 
    force_ssl 
    helper :all 
    protect_from_forgery 
    set_current_tenant_by_subdomain(:account, :subdomain) # need to skip this call when in the admin namespace 
    before_filter :require_user # need to skip this call when in the admin namespace 
end 

感謝您的幫助!

回答

3

您可以創建一個BaseController,其中包括set_current_tenant_by_subdomainbefore_filter :require_user,並讓您的非管理員控制器繼承該管理員控制器,而您的管理員控制器直接從ApplicationController繼承。這在過去對我很有用。

+0

這樣做了。謝謝你的幫助! – lundie 2012-03-21 18:13:18

1
在配置/初始化

/active_admin.rb你可以添加一行:

config.skip_before_filter :offending_filter 

可悲的是這樣做除了儀表盤控制器...爲了你的應用需要

controller do 
    skip_before_filter :offending_filter 
end 

一切/ admin/dashboard.rb