Skip to content

Ruby on Rails Administration Engine

License

Notifications You must be signed in to change notification settings

afomera/madmin-old

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

44 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Madmin

Short description and motivation.

Usage

How to use my plugin.

Installation

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

Generating Resources

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

Implementing Authentication

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

Autoloading Lib

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/**/"]

Contributing

Contribution directions go here.

License

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

About

Ruby on Rails Administration Engine

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published