Short description and motivation.
How to use my plugin.
Add this line to your application's Gemfile:
gem 'madmin'
And then execute:
$ bundle
Or install it yourself as:
$ gem install madmin
Then you can run the installer to generate resources for all models in
your app that inherit from ActiveRecord::Base
by running:
rails generate madmin:install
To generate (or re-generate) a Madmin dashboard for a resource, you can run the following command and pass in the model name
rails generate madmin:install User
To implement user authentication for your admin dashboard, you can override authenticate!
in app/controllers/madmin/application_controller.rb
.
To access this controller run the following command
rails generate madmin:controller Application
If you're using Devise, simply have authenticate!
authenticate your resource
class Madmin::ApplicationController < Madmin::BaseController
...
private
def authenticate!
authenticate_user!
end
end
If you're wanting to use simple HTTP Basic authentication, have authenticate!
use authenticate_with_http_basic
like the following
class Madmin::ApplicationController < Madmin::BaseController
...
private
def authenticate!
authenticated = authenticate_with_http_basic { |user, password|
user == "user" && password == "password"
}
request_http_basic_authentication unless authenticated
end
end
If you want to avoid having to restart your Rails application everytime you make an adjustment to a lib/madmin/resources.rb
, add the following to config/application.rb
:
# Autoload Madmin
config.autoload_paths += Dir["#{config.root}/lib/madmin/**/"]
Contribution directions go here.
The gem is available as open source under the terms of the MIT License.