Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to keep DRY with a ActiveAdmin or RailsAdmin, separate from the main application

I am building a JSON-only application, it is basically a leaner Rails, with fewer middleware and fewer modules. This is an application being built in Rails 4.

I want to to develop a simple app that can administrate the data in the database for the main-app. For this I would like to use Active Admin or Rails Admin. But both options somehow use the underlying models and their validations, requirements and such to build on top of.

This means that I need to share at least the models between the main application and the RailsAdmin application.

How would I best do this? Is there a good guide on how to build an administration-application in a separate rails app next to your main one, instead of having it integrated?

As a side note: another good reason to keep the admin in a separate application from the main app, but on a shared database, is the myriad of dependencies, a gem like ActiveAdmin comes with.

Also note that I am not simply interested in running admin on a different domain or different server, but mostly to keep main app lean and focused. And to keep the dependencies with which something like ActiveAdmin comes, out of my main app.


footnotes:

  • Neither ActiveAdmin nor RailsAdmin are problems for performance in themselves. It's that they require middleware, whereas a JSON-only Rail-app, needs only very few modules, helpers and middleware! Rails-API, offers such a slim stack. Performance is not about Admin vs. no admin, but Full-Rails vs Rails-API.
  • Performance is not my main problem, the dependencies and bloat is! I now have a Rails application that is so slim, focused and lean, that it can measure itself with most Sinatra apps :). With only three additional gems (each with a few dependencies of their own) and a very thin stack of middleware, I can upgrade, manage and debug very easily.

More practical: I don't have Devise (It's a JSON-API, so token-authenticated), don't have any views or template-engine. No Formtastic, No Paperclip, Rmagic, Kminari (pagers) and so on and so forth. All of which will be added to my app when I pull in "just an admin".

like image 572
berkes Avatar asked Aug 08 '13 18:08

berkes


2 Answers

This blog post describes an interesting approach: https://content.pivotal.io/blog/migrating-from-a-single-rails-app-to-a-suite-of-rails-engines

They use a nearly empty app as a container and mount their actual apps as Rails Engines.

like image 135
attilakreiner Avatar answered Sep 22 '22 14:09

attilakreiner


did you measure the impact of adding tools like ActiveAdmin to the speed of your rest API? if not, this sounds like a case of premature optimization to me.

in the case that the API speed really has an impact by a library that is loaded but not used, then you could create multiple applications and share the models in a git submodule.

like image 36
phoet Avatar answered Sep 20 '22 14:09

phoet