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.
- Ruby ~> 2.3
Add SimpleAdmin to your application's Gemfile:
gem 'simpleadmin'
And then run:
bundle install
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
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
Bug reports and pull requests are welcome on GitHub at https://github.com/getsimpleadmin/simpleadmin.
The gem is available as open source under the terms of the MIT License.