I alway use something like ActiveAdmin or RailsAdmin when quickly putting together an app (even if initially) with Rails - they are just so convenient and help you concentrate on the app itself.
What do you do or use with Phoenix? Prefer to roll your own or use something like Ex Admin?
Applications with “users” are naturally heavily user driven. After all, our software is typically designed to be used by human end-users one way or another. Instead of extending our Accounts.User struct to track every field and responsibility of our entire platform, it’s better to keep those responsibilities with the modules who own that functionality. In our case, we can create a CMS.Author struct that holds author specific fields as it relates to a CMS. Now we can place fields like “role” and “bio” here, where they naturally live. Likewise, we also gain specialized datastructures in our application that are suited to the domain that we are operating in, rather than a single %User{} in the system that has to be everything to everyone.
But knowing that the ideas may differ, what are your thoughts about his opinion/point of view?
I’m working on an admin backend inspired by torch and ex_admin. The core component is a library to generate ecto queries dynamically from phoenix params (also written by me) which I haven’t released yet. I can’t guarantee the API stability of this library yet, though…
If people are interested in trying it I might publish it (as super alpha software) . It’s already quite functional, actually.
It makes heavy use of generators, so it’s closer to torch than ex_admin. IMO, the main advantage over torch is that the generated code (especially the templates) are a bit cleaner and easier to extend, and I think it supports a little more features.
I tried both Torch and ExAdmin but didn’t like either so I built the admin interface using the Phoenix generators. It’s been really easy to work with, and so far it’s felt like the better option to opt for. This was done in an umbrella app setup with multiple Phoenix apps.
You can slap on a Bootstrap admin template, add a user authentication library, and have it up and running in no time.
Hi @danschultzer . Can you share more details on how you generated your stuff? Especially, how do you interact with the contexts made in your main app?
Run with --no-context and --no-schema if you already have the context and schema. The mix tasks generates all you need for the admin interface.
You can also generate an admin context module for list/get/create/update methods. The generator will set it up so you can see how you interact with your context app from your controllers.
Okay ! If you want to make the Admin panel for a context Blog and a schema Post, what would be in the Controller of the admin/Post ? Will it be a plain copy of the basic PostController?
If the PostController is generated with the mix task, yeah. If not, then I would first generate the controllers/context with e.g. mix phx.gen.html BlogAdmin Post blog_posts title:string content:text --no-schema and then use the generated code.