ZenAdmin

Rails engine for admin interface with Headless API and Bootstrap UI.

Installation

Add this line to your application's Gemfile:

gem "zen_admin"

And then execute:

$ bundle

Or install it yourself as:

$ gem install zen_admin

Usage

  1. Mount the engine in your routes:

    # config/routes.rb
    mount ZenAdmin::Engine => "/admin"
    
  2. Configure ZenAdmin:

    # config/initializers/zen_admin.rb
    ZenAdmin.configure do |config|
     config.enable_ui = true
     config.admin_path = "/admin"
    end
    
  3. Register your models:

    # config/initializers/zen_admin.rb
    ZenAdmin.register(User) do |resource|
     resource.list do
       field :email
       field :name
     end
    
     resource.form do
       field :email, type: :string, required: true
       field :name, type: :string
     end
    
     resource.filters do
       filter :email
     end
    end
    
  4. Access the admin interface at /admin

API Endpoints

  • GET /admin/api/schema/:resource - Get resource schema
  • GET /admin/api/resources/:resource_name - List resources
  • POST /admin/api/resources/:resource_name - Create resource
  • GET /admin/api/resources/:resource_name/:id - Show resource
  • PUT /admin/api/resources/:resource_name/:id - Update resource
  • DELETE /admin/api/resources/:resource_name/:id - Delete resource

UI Pages

  • /admin/ui/:resource_name - List resources
  • /admin/ui/:resource_name/new - New resource form
  • /admin/ui/:resource_name/:id/edit - Edit resource form

Contributing

Contribution directions go here.

License

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