IronAdmin
Convention-over-configuration admin panel engine for Ruby on Rails. Build beautiful admin interfaces with minimal code.
Features
- Zero Configuration CRUD - Auto-generates forms and tables from your database schema
- Resource DSL - Customize fields, filters, scopes, and actions with a clean Ruby DSL
- Dashboard Builder - Create metrics, charts, and recent records widgets
- Theme System - Fully customizable Tailwind CSS classes for every UI element
- Authorization - Built-in policy system for fine-grained access control
- Search - Global search across all resources
- Export - CSV and JSON export out of the box
Requirements
- Ruby >= 3.2
- Rails >= 7.1
- tailwindcss-rails >= 4.0
Installation
Add to your Gemfile:
gem "iron_admin"
gem "tailwindcss-rails"Then run:
bundle install
rails generate iron_admin:installThe install generator will:
- Create
app/iron_admin/resources/andapp/iron_admin/dashboards/directories - Add a configuration initializer at
config/initializers/iron_admin.rb - Create a sample dashboard
- Mount the engine at
/adminin your routes - Add the IronAdmin Tailwind CSS import to your
app/assets/tailwind/application.css
Tailwind CSS Setup
IronAdmin uses Tailwind CSS v4 for all styling. The tailwindcss-rails gem handles
compilation. After running the install generator, your app/assets/tailwind/application.css
should include:
@import "tailwindcss";
@import "../builds/tailwind/iron_admin";The second line imports IronAdmin's @source directives so the Tailwind compiler
scans the engine's views and components for CSS classes. Without it, the admin panel
will render unstyled.
If you're setting up manually (without the generator), run:
rails tailwindcss:buildThen verify that app/assets/builds/tailwind/iron_admin.css was created. If not,
check that tailwindcss-rails >= 4.0 is installed and that the engine gem is properly
loaded.
For development, use bin/dev or rails tailwindcss:watch to recompile CSS on changes.
Quick Start
1. Configure Authentication
# config/initializers/iron_admin.rb
IronAdmin.configure do |config|
config.title = "My App Admin"
config.authenticate do |controller|
user = User.find_by(id: controller.session[:user_id])
controller.redirect_to "/login" unless user&.admin?
end
config.current_user do |controller|
User.find_by(id: controller.session[:user_id])
end
end2. Generate Resources
rails generate iron_admin:resource User
rails generate iron_admin:resource Product
rails generate iron_admin:resource Order3. Customize Resources
# app/iron_admin/resources/user_resource.rb
module IronAdmin
module Resources
class UserResource < IronAdmin::Resource
field :role, type: :badge, colors: { admin: :purple, user: :blue }
field :email, type: :text
searchable :name, :email
filter :role, type: :select, choices: User.roles.keys
filter :created_at, type: :date_range
scope :admins, -> { where(role: :admin) }
scope :recent, -> { where("created_at > ?", 7.days.ago) }
index_fields :id, :name, :email, :role, :created_at
form_fields :name, :email, :role
menu priority: 1, icon: "users", group: "People"
action :lock, icon: "lock-closed", confirm: true do |record|
record.update!(locked_at: Time.current)
end
end
end
end4. Create a Dashboard
# app/iron_admin/dashboards/admin_dashboard.rb
module IronAdmin
module Dashboards
class AdminDashboard < IronAdmin::Dashboard
metric :total_users, format: :number do
User.count
end
metric :monthly_revenue, format: :currency do
Payment.where("created_at > ?", 30.days.ago).sum(:amount)
end
recent :users, limit: 5, scope: -> { order(created_at: :desc) }
recent :payments, limit: 5
end
end
endVisit /admin and your admin panel is ready!
Documentation
Full documentation is available in the docs directory:
Development
After checking out the repo:
bundle install
bundle exec rspec
bundle exec rubocopContributing
See CONTRIBUTING.md for details.
License
The gem is available as open source under the terms of the MIT License.