Building separate admin app for SaaS product

We have a mutli-tenant SaaS Rails app and we’re looking to add an admin section for ourselves as owners/developers so we can get an overview of how the app is being used, how many resources our users are creating and how they engage with new features.

I used the dreaded default_scope to set up multi-tenancy so accessing tenant data across the board is difficult from within the Rails app.

Would it be more sensible to create a separate Rails app that has read access to the main database than to try to work around all the scoping in the main app?

I think you should avoid a separate app. Duplicating all the model validation/domain logic that you’ve already built is a painful, error prone task.

You should check out Administrate, RailsAdmin, and ActiveAdmin to see is one of those solutions might fit your needs.

If you have to roll your own, do it in the same app. Try creating an AdminController base controller that you can use that authorizes admin users and redirects non-admin users out. Administrative pages can then inherit from the AdminController.

1 Like

Hey @weavermedia,

Just curious how you ended up implementing your admin section.

Did you create a separate Rails app or put it into the same one? If the latter, how did you work around your default_scope issue? Did it require more work than calling .unscoped on the resources?

Would love to hear how your solution turned out. Thanks!