rademade_admin
Best rails admin panel!
How to use it
-
Add
gem 'rademade_admin'
to Gemfile -
Update
config/initializers/assets.rb
with line:
config.assets.precompile += %w(rademade_admin.css rademade_admin.js)
-
Mount rails engine at routing.rb
mount RademadeAdmin::Engine => '/rademade_admin
-
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
- Add rademade_admin initializer
initializers/rademade_admin.rb
RademadeAdmin.configure do |config|
config.admin_class = User
end
- 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
- Add
admin_resources
torouters.rb
namespace :rademade_admin, :path => 'admin' do
admin_resources :users
end
-
Install assets with bower
rake rademade_admin:bower:install
-
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