Adminable
Simple admin interface for Ruby on Rails applications.
Features
- Built with common Rails controllers and views without DSL.
- Supports namespaced models.
- Has simple search with Ransack.
- Uses Bootstrap 4.0.
- Handles a lot of associations with Clusterize.js.
- Has built-in WYSIWYG editor TinyMCE.
- Mobile friendly.
Installation
Add this line to your application's Gemfile:
gem 'adminable'And then execute:
$ bundleOr install it yourself as:
$ gem install adminableGetting Started
First things first. Add routes and create adminable/application_controller.rb class using generator:
rails g adminable:install
# => create app/controllers/adminable/application_controller.rb
# => insert config/routes.rbGenerating Resources
Assume you have model User, then run:
rails g adminable:resource users
# => create app/controllers/adminable/users_controller.rbFor namespaced models, like Blog::Post, use:
rails g adminable:resource blog/posts
# => create app/controllers/adminable/blog/posts_controller.rbCustomizing Fields
Change fields as you like inside fields method array:
class Adminable::Blog::PostsController < Adminable::ResourcesController
def fields
[
Adminable::Fields::Integer.new(:id, form: false),
Adminable::Fields::String.new(:title),
Adminable::Fields::Text.new(:body),
Adminable::Fields::Float.new(:rating, form: false),
Adminable::Fields::Boolean.new(:published),
Adminable::Fields::BelongsTo.new(:user),
Adminable::Fields::HasMany.new(:blog_comments)
]
end
endFields Parameters
index
true or false, default: true.
Shows field on index page.
form
true or false, default: true.
Shows field on new/edit page.
center
true or false, default true for integer, boolean, float and decimal fields, false otherwise.
Adds text-align: center for field value on index page.
search
true or false, default: false.
Enables search for this field.
See Also
- Configured controller for Devise model: app/controllers/adminable/users_controller.rb
Built-in Fields
- String
- Text
- Integer
- Float
- Decimal
- Date
- DateTime
- Time
- Timestamp
- Boolean
- Belongs To
- Has Many
Generating Partials
You can use generator to copy original partial to your application.
rails g adminable:partial [layout] [type] [resource]
-
layout-indexorform. -
type-string,textetc. See Built-in Fields. -
resource- Use controller name (e.g.users) to replace partial only for single controller or leave blank to replace partials for all controllers.
F.A.Q
If model to_param method was overridden
class Adminable::Blog::PostsController < Adminable::ResourcesController
def set_entry
entry = @resource.model.find_by(slug: params[:id])
super
end
endContributing
- Fork it (https://github.com/droptheplot/adminable/fork)
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create new Pull Request
License
The gem is available as open source under the terms of the MIT License.

