rails_admin
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
Top Related Projects
The administration framework for Ruby on Rails applications.
A Rails engine that helps you put together a super-flexible admin dashboard.
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
Quick Overview
Rails Admin is a Rails engine that provides an easy-to-use interface for managing your data in Ruby on Rails applications. It automatically generates an admin interface by inferring from your models, offering a flexible and customizable solution for content management and data administration.
Pros
- Easy setup and integration with existing Rails applications
- Automatic CRUD interface generation based on your models
- Highly customizable with a wide range of configuration options
- Supports various authentication systems and authorization frameworks
Cons
- Can be overkill for simple applications or small datasets
- Performance may degrade with large amounts of data or complex relationships
- Customization beyond basic options may require diving into the source code
- Some users report occasional compatibility issues with certain Rails versions
Code Examples
- Basic setup in
config/initializers/rails_admin.rb
:
RailsAdmin.config do |config|
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
end
- Customizing model configuration:
RailsAdmin.config do |config|
config.model 'User' do
list do
field :id
field :email
field :created_at
end
edit do
field :email
field :password
field :roles
end
end
end
- Adding a custom action:
RailsAdmin.config do |config|
config.actions do
dashboard
index
new
export
bulk_delete
show
edit
delete
show_in_app
member :publish do
i18n_key :publish
controller do
proc do
@object.publish!
flash[:notice] = "#{@model_config.label} published!"
redirect_to back_or_index
end
end
end
end
end
Getting Started
-
Add to your Gemfile:
gem 'rails_admin', '~> 3.0'
-
Run:
bundle install
-
Run the generator:
rails g rails_admin:install
-
Provide a namespace for the routes when asked
-
Start your server and visit
/admin
Competitor Comparisons
The administration framework for Ruby on Rails applications.
Pros of Active Admin
- More intuitive and user-friendly interface
- Better documentation and community support
- Easier customization of views and dashboards
Cons of Active Admin
- Less flexible for complex admin panel requirements
- Steeper learning curve for advanced customizations
- More opinionated, which can limit some design choices
Code Comparison
Active Admin:
ActiveAdmin.register Post do
permit_params :title, :body, :published_at
index do
selectable_column
column :title
column :published_at
actions
end
end
Rails Admin:
RailsAdmin.config do |config|
config.model 'Post' do
list do
field :title
field :published_at
end
edit do
field :title
field :body
field :published_at
end
end
end
Both Active Admin and Rails Admin are popular gems for creating admin interfaces in Ruby on Rails applications. Active Admin offers a more polished out-of-the-box experience with better documentation and community support. It's generally easier to set up and customize for basic admin needs. However, Rails Admin provides more flexibility for complex admin panel requirements and may be preferred for projects that need fine-grained control over the admin interface. The code comparison shows that Active Admin uses a more declarative syntax, while Rails Admin offers a more configuration-based approach.
A Rails engine that helps you put together a super-flexible admin dashboard.
Pros of Administrate
- More customizable and flexible, allowing for easier tailoring to specific project needs
- Cleaner, more modern UI design out of the box
- Better integration with Rails conventions and patterns
Cons of Administrate
- Less feature-rich compared to Rails Admin, requiring more manual setup for advanced functionality
- Smaller community and ecosystem, potentially leading to fewer resources and third-party extensions
Code Comparison
Administrate dashboard configuration:
class ProductDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = {
id: Field::Number,
name: Field::String,
price: Field::Number.with_options(prefix: "$", decimals: 2),
created_at: Field::DateTime,
updated_at: Field::DateTime,
}
# ... other configuration
end
Rails Admin configuration:
RailsAdmin.config do |config|
config.model 'Product' do
list do
field :id
field :name
field :price do
formatted_value do
"$#{value.to_f.round(2)}"
end
end
field :created_at
field :updated_at
end
end
end
Both libraries offer ways to customize the admin interface, but Administrate's approach is more aligned with Rails conventions, using a dedicated dashboard class. Rails Admin, on the other hand, uses a DSL within a configuration block, which can be more concise but potentially less intuitive for complex setups.
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
Pros of rails_admin
- More active development and maintenance
- Larger community and contributor base
- Better documentation and support resources
Cons of rails_admin
- Potentially more complex setup and configuration
- May have more features than needed for simpler projects
- Slightly larger footprint and resource usage
Code Comparison
rails_admin:
RailsAdmin.config do |config|
config.authenticate_with do
warden.authenticate! scope: :user
end
config.current_user_method(&:current_user)
end
rails_admin>:
RailsAdmin.config do |config|
config.authenticate_with do
authenticate_or_request_with_http_basic do |username, password|
username == 'admin' && password == 'password'
end
end
end
The code comparison shows that both repositories use similar configuration blocks, but rails_admin offers more flexibility in authentication methods, while rails_admin> uses a simpler, basic HTTP authentication approach.
Both repositories provide admin panel functionality for Ruby on Rails applications, but rails_admin is generally considered more feature-rich and actively maintained. However, rails_admin> might be a good choice for simpler projects or those requiring a more lightweight solution.
ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
Pros of Comfortable Mexican Sofa
- More focused on content management and website building
- Offers a simpler and more intuitive interface for non-technical users
- Provides built-in templating system for easier content creation
Cons of Comfortable Mexican Sofa
- Less flexible for general-purpose admin tasks
- Smaller community and fewer extensions compared to Rails Admin
- May require more customization for complex data models
Code Comparison
Rails Admin configuration:
RailsAdmin.config do |config|
config.actions do
dashboard
index
new
export
bulk_delete
end
end
Comfortable Mexican Sofa setup:
ComfortableMexicanSofa::AccessControl::AdminAuthentication.class_eval do
def authenticate
return true if current_user.try(:admin?)
redirect_to root_path
end
end
Both projects offer different approaches to admin interfaces in Rails applications. Rails Admin provides a more general-purpose solution for managing database records, while Comfortable Mexican Sofa focuses on content management and website building. The choice between the two depends on the specific needs of your project, with Rails Admin being more suitable for complex data models and Comfortable Mexican Sofa excelling in content-centric applications.
Pros of Inherited Resources
- Lightweight and focused on resource-oriented controllers
- Easier to customize and extend for specific use cases
- Better integration with existing Rails applications
Cons of Inherited Resources
- Less out-of-the-box functionality compared to Rails Admin
- Requires more manual setup and configuration
- Limited built-in UI components
Code Comparison
Inherited Resources:
class ProductsController < InheritedResources::Base
actions :all, except: [:destroy]
end
Rails Admin:
RailsAdmin.config do |config|
config.model 'Product' do
list do
field :name
field :price
end
end
end
Inherited Resources focuses on simplifying controller logic, while Rails Admin provides a comprehensive admin interface configuration. Inherited Resources is more suitable for developers who want fine-grained control over their admin interfaces and are willing to build more custom functionality. Rails Admin, on the other hand, offers a more complete out-of-the-box solution with less customization required for basic admin panel functionality.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
RailsAdmin
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.
Getting started
- Check out the docs.
- Try the live demo. (Source code)
Features
- CRUD any data with ease
- Custom actions
- Automatic form validation
- Search and filtering
- Export data to CSV/JSON/XML
- Authentication (via Devise or other)
- Authorization (via CanCanCan or Pundit)
- User action history (via PaperTrail)
- Supported ORMs
- ActiveRecord
- Mongoid
Installation
- On your gemfile:
gem 'rails_admin', '~> 3.0'
- Run
bundle install
- Run
rails g rails_admin:install
- Provide a namespace for the routes when asked
- Start a server
rails s
and administer your data at /admin. (if you chose default namespace: /admin)
Upgrading from 2.x
Due to introduction of Webpack/Webpacker support, some additional dependency and configuration will be needed.
Running rails g rails_admin:install
will suggest you some required changes, based on current setup of your app.
Configuration
Global
In config/initializers/rails_admin.rb
:
To begin with, you may be interested in setting up Devise, CanCanCan or Papertrail!
Per model
class Ball < ActiveRecord::Base
validates :name, presence: true
belongs_to :player
rails_admin do
configure :player do
label 'Owner of this ball: '
end
end
end
Details: Models, Groups, Fields
Support
If you have a question, please check this README, the wiki, and the list of known issues.
If you still have a question, you can ask the official RailsAdmin mailing list.
If you think you found a bug in RailsAdmin, you can submit an issue.
Supported Ruby Versions
This library aims to support and is tested against the following Ruby implementations:
- Ruby 2.6
- Ruby 2.7
- Ruby 3.0
- Ruby 3.1
- Ruby 3.2
- JRuby
Top Related Projects
The administration framework for Ruby on Rails applications.
A Rails engine that helps you put together a super-flexible admin dashboard.
RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot