Adminable

Gem Version Build Status Code Climate Test Coverage Dependency Status

Simple admin interface for Ruby on Rails applications.

Features

  • Built with common Rails controllers with a small 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.

Example1

Example2

Installation

Add this line to your application's Gemfile:

gem 'adminable'

And then execute:

$ bundle

Or install it yourself as:

$ gem install adminable

Getting Started

First things first. Add routes and create application_controller.rb class using generator:

rails g adminable:install
# => create app/controllers/adminable/application_controller.rb
# => insert config/routes.rb

Generating Resources

For example you have model User, then run:

rails g adminable:resource user
# => create  app/controllers/adminable/users_controller.rb

For namespaced models, like Blog::Post, use:

rails g adminable:resource blog/post
# => create  app/controllers/adminable/blog/posts_controller.rb

Customizing Attributes

You can update attributes with simple DSL inside set_attributes block:

For existing attributes
  set(name, options = {})
For new attributes
  add(name, type, options = {})
Attributes Parameters
  • index - (true/false) - Shows attribute on index page.
  • form - (true/false) - Shows attribute on new/edit page.
  • center - (true/false) - Adds text-align: center for attribute value on index page.
  • search - (true/false) - Enables search for this attribute.
Examples
class Adminable::Blog::PostsController < Adminable::ResourcesController
  set_attributes do |attributes|
    # Enables search for title column
    attributes.set :title, search: true

    # Hides title from new and edit pages
    attributes.set :title, form: true

    # Adds wysiwyg plugin and hides from index table
    attributes.set :text, wysiwyg: true, index: false

    # Adds new attribute `password` with type `string` and some options
    attributes.add :password, :string, wysiwyg: true, index: false

    # Adds new attribute `author`
    attributes << Adminable::Attributes::Types::String.new(:author)

    # Allows search for multiple attributes
    attributes.set :title, :body, search: true
  end
end
See Also

Built-in Attributes

List of attributes with default parameters.

index form center wysiwyg
String + +
Text + + +
Integer + + +
Float + + +
Decimal + + +
Date + +
DateTime + +
Time + +
Timestamp + +
Boolean + + +
Belongs To +
Has Many +

Contributing

  1. Fork it (https://github.com/droptheplot/adminable/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

The gem is available as open source under the terms of the MIT License.