Skip to content

Latest commit

 

History

History
97 lines (67 loc) · 3.12 KB

README.md

File metadata and controls

97 lines (67 loc) · 3.12 KB

Build Status codecov.ioGem Version

SimpleAdmin provides builder for administrative dashboards, it's fit for Web / Mobile / API. Cloud or your own servers, depends on your choice and requirements.

All common admin dashboard tasks like content create / update / delete operations, charts, invite colleagues.

This is API Rack Application to connect your application with SimpleAdmin service.

Example Application

Requirements

  • Ruby ~> 2.3

Installation

simple_admin

Add SimpleAdmin to your application's Gemfile:

gem 'simpleadmin'

And then run:

bundle install

Configuration in Ruby on Rails

Just run next command:

rails generate simpleadmin:install

It will automatically add initializer and SimpleAdmin API routes. Default secret key for your application:

SECRET_KEY

Don't forget to change it in production

Configuration in Hanami, Sinatra and etc.

Add the next line to your routes file to mount simpleadmin built-in routes:

# config/routes.rb
Rails.application.routes.draw do
  mount Simpleadmin::Application, at: 'simpleadmin'
end

Create initializer, add your secret key and restart server

# config/initializers/simpleadmin.rb
ENV['SIMPLE_ADMIN_SECRET_KEY'] = 'SECRET_KEY'

Simpleadmin::Config.setup do |config|
    #  For Ruby on Rails, you don't need to define database credentials directly, 
    #  also when you deployed it on Heroku. In other cases define database 
    #  credentials using the syntax below
    config.database_credentials = {
       adapter: :postgres,
       database: 'demo_development'
    }
    
    # By default all tables permitted, but you can select what tables you want to use in the admin panel
    config.allowed_tables = ['users', 'orders']
   
    #  DSL to describe CRUD actions in an application. In Ruby on Rails, you don't need to define it 
    config.on_create = lambda do |model_class, resource_params|
      model_class.create(resource_params)
    end

    config.on_update = lambda do |model_class, resource_id, resource_params|
      model_class.find(resource_id).update(resource_params)
    end

    config.on_destroy = lambda do |model_class, resource_id|
      model_class.find(resource_id).destroy
    end
end

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/getsimpleadmin/simpleadmin.

License

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