lundie
lundie

Reputation: 367

How to skip application_controller calls only when within a certain namespace (ActiveAdmin)

I am attempting to use active admin with a project. This project also uses another gem to separate out different tenants, as well as has_secure_password for normal authentication.

I am having an issue skipping both of these filters when the user goes to active admin (just a different namespace - admin).

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

Thanks for your help!

Upvotes: 2

Views: 420

Answers (2)

fringd
fringd

Reputation: 2538

in config/initializers/active_admin.rb you can add the line:

config.skip_before_filter :offending_filter

sadly this does everything except the dashboard controller... for that you need

controller do
  skip_before_filter :offending_filter
end

in app/admin/dashboard.rb

Upvotes: 1

Eric K
Eric K

Reputation: 395

You could create a BaseController that includes set_current_tenant_by_subdomain and before_filter :require_user and have your non-admin controllers inherit from that, while your admin controller inherits directly from the ApplicationController. That's worked for me in the past.

Upvotes: 3

Related Questions