
Template details
Madmin
A robust Admin Interface for Ruby on Rails apps
About this template
Madmin is an open-source Ruby on Rails engine that generates a customizable admin interface from your existing models, producing resource controllers, views, and fields with minimal DSL.
What is Madmin?
Madmin is a Rails engine that mounts an admin area into your Ruby on Rails application. It takes your ActiveRecord models and generates resource classes and CRUD views automatically, and outputs a working admin dashboard. It is maintained by excid3 and distributed as a gem under the MIT License. It is designed to be familiar to Rails developers because it builds on standard Rails scaffolds rather than introducing a heavy new DSL.
Key Features
Madmin provides a set of generator-based customization options, deep Rails integration, and a minimal DSL that stays close to standard scaffolds. The main features include:
- Scaffold-like resources — Madmin generates a Resource class for each model (via
rails g madmin:resource), and the views reuse standard Rails action views (index, new, edit, show, and _form) that you can override with generators. - Rails feature support — Works out of the box with ActionText, ActionMailbox, has_secure_password, and other Rails features.
- Hotwire-ready — Ships with Stimulus / Turbolinks / Hotwire integration and works with Import maps and Sprockets.
- View generators —
rails g madmin:viewscopies the layout, navigation, JavaScript, and per-resource views into your app for customization; you can scope to a single model (e.g.rails g madmin:views:index Book). - Field type customization — Set a field type as the second argument on an attribute (e.g.
attribute :genre, :select, collection: [...]) or generate a custom field withrails g madmin:field Custom, producing_form,_index, and_showpartials. - Per-view attribute visibility — The
attributemethod accepts options likeform: false,index: false, andshow: falseto control where a field appears. - N+1 query prevention — Override
scoped_resourcesin the generated controller and addincludes(...)to eager-load associations. - Authentication strategies — The README links to authentication docs for gating access to the admin panel.
Who is it for?
Madmin is aimed at Ruby on Rails developers who want a quick, customizable admin backend without adopting a separate admin framework. It suits teams that are comfortable with Rails conventions (scaffolds, partials, generators) and want full control over the generated views. It is also useful for developers building internal tools who need to maintain a familiar Rails structure.
What can you do with Madmin?
Madmin lets you generate, customize, and optimize an admin interface entirely within your Rails project. Use cases include:
- Rails developers: Generate a working admin panel for existing models in minutes with
rails g madmin:install, which creates resources for every model it finds. - Customizing admins: Override any generated view — index, show, new, edit, form, navigation, or layout — using the scoped view generators, and adjust field visibility per action.
- Handling complex data: Preload associations to avoid N+1 queries by overriding
scoped_resourcesin the resource controller.
How does Madmin work?
Madmin works as a Rails engine: you add the gem, run the installer, and it generates resource and view files that you can further refine. Install with bundle add madmin, run rails g madmin:install to generate resources for each model, then use generators like rails g madmin:resource and rails g madmin:views to add or copy views.
FAQ
Is Madmin free?
Yes, Madmin is open source and released under the MIT License.
Does Madmin support Rails 7 and Hotwire?
Yes, it is designed to work with Stimulus, Turbolinks, and Hotwire, and supports both Import maps and Sprockets for asset handling.
How do I add a custom field type?
Run rails g madmin:field Custom to generate a CustomField class and the corresponding partials, then use it in a resource with attribute :title, field: CustomField.
Can I customize the views per model?
Yes, you can run generators like rails g madmin:views:index Book to copy only the index view for the Book resource, and then edit it in your app.
How do I avoid N+1 queries?
Override the scoped_resources method in the model's Madmin controller and chain .includes(:association) before returning.
















