/rademade_admin

Best rails admin panel!

Primary LanguageRubyMIT LicenseMIT

rademade_admin

Gem Version Build Status Coverage Status Code Climate PullReview stats

Best rails admin panel!

How to use it

  1. Add gem 'rademade_admin' to Gemfile

  2. Update config/initializers/assets.rb with line:

config.assets.precompile += %w(rademade_admin.css rademade_admin.js)
  1. Mount rails engine at routing.rb mount RademadeAdmin::Engine => '/rademade_admin

  2. Create User model and other needed models

# encoding: utf-8
require 'digest/sha1'

class User
  include Mongoid::Document
  include RademadeAdmin::UserModule

  field :first_name, :type => String
  field :email, :type => String
  field :encrypted_password, :type => String
  field :admin, :type => Boolean, :default => false

  def self.get_by_email(email)
    self.where(:email => email).first
  end

  def password=(password)
    self[:encrypted_password] = encrypt_password(password) unless password.blank?
  end

  def valid_password?(password)
    self[:encrypted_password] == encrypt_password(password)
  end

  def to_s
    email
  end

  private

  def encrypt_password(password)
    Digest::SHA1.hexdigest(password)
  end

end
  1. Add rademade_admin initializer initializers/rademade_admin.rb
RademadeAdmin.configure do |config|
  config.admin_class = User
end
  1. Create admin controller. Example app/controllers/rademade_admin/users_controller.rb
class RademadeAdmin::UsersController < RademadeAdmin::ModelController

  # You can leave controller absolutely empty!
  
  options do
    list do
      email
    end
    form do
      first_name
      email
      password :hint => 'Or leave it empty'
    end
  end

end
  1. Add admin_resources to routers.rb
namespace :rademade_admin, :path => 'admin' do
  admin_resources :users
end
  1. Install assets with bower rake rademade_admin:bower:install

  2. Start rails rails s

Good luck :)

Supported options

options do
  model 'ModelName'
  
  # Navigation menu settings
  parent_menu 'ModelName'

  # Setting for list data (index action)
  # list :attr, :attr_other
  list do
    
  end
  
  # Settings for form
  # form :attr, :attr_other
  form do
    attr :boolean #Other :text, :file, :editor
  end
  
  labels do
    attr 'Label for attribute'
  end
  
end