Moeki Kawakami

The Admin Framework for Minimalist

thoughtbot/administrate is a well-known framework for administrative screen, but it's not developer friendly。I implement my own template files for Administrate, so when new Administrate version released, it is hard to update Administrate because template file is changed.

But administrative screens are very easy to commonize, so I want to use a framework or library.

I done this.

cc-kawakami/micro-admin: A minimal Administration dashboard parts.

It can be used with Ruby on Rails or other frameworks because I implemented with trailblazer/cells.

You can define ApplicationDashboard.

class ApplicationDashboard < MicroAdmin::Dashboard::Base
    # もし Rails を使うなら
    self.view_paths = [Rails.root.join("app", "views", "dashboards")]

And you extends it, define dashboard classes for models and define attributes to show each screens.

class UserDashboard < ApplicationDashboard
    def index_attributes
        [:id, :name]

    def show_attributes
        [:id, :name]

    def form_attributes

    def model_class

It is a point, MicroAdmin does not have template for form items. So you must write template files for input or select , etc.


<input type="text" name="name" class="form-control">

The value variable will come to the edit template.


<input type="text" name="name" value="<%= value %>" class="form-control">

It can be rendered by calling the following.

smith = 1, name: "Smith")
james = 1, name: "James")
dashboard =
<%= dashboard.index([smith, james]) %>
<%= %>
<%= ["Name is required!"]) %>
<%= dashboard.edit(id: 1, values: {name: "Smith"}, errors: []) %>

As an example, the edit method output HTML like this.

<header class="navbar border-bottom py-4">
  <h2 class="m-0">Create TestModel</h2>
    <a href="/admin/user" class="btn btn-primary"> Back to index </a>
<main class="p-4">
  <ul class="alert alert-danger">
    <li class="ml-3">Name is required</li>
  <form method="patch" action="/admin/user/1">
    <div class="mb-3">
      <label for="name" class="form-label">name</label>
      <input type="text" name="name" value="Smith" class="form-control" />

And you can style the screens by loading Bootstrap!

The points:

  • the html of form item is customizable
  • not only Ruby on Rails

Thank you.

← Back to list