add administrate
This commit is contained in:
4
Gemfile
4
Gemfile
@@ -15,12 +15,14 @@ gem "webpacker", "~> 5.0"
|
||||
|
||||
gem "bootsnap", ">= 1.4.4", require: false
|
||||
|
||||
gem "administrate"
|
||||
|
||||
gem "devise"
|
||||
gem "devise-bootstrap-views", "~> 1.0"
|
||||
gem "devise-i18n"
|
||||
|
||||
group :development, :test do
|
||||
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
|
||||
gem "pry-byebug", platforms: [:mri, :mingw, :x64_mingw]
|
||||
gem "capybara"
|
||||
gem "rspec-rails"
|
||||
|
||||
|
||||
41
Gemfile.lock
41
Gemfile.lock
@@ -62,6 +62,16 @@ GEM
|
||||
zeitwerk (~> 2.3)
|
||||
addressable (2.8.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
administrate (0.16.0)
|
||||
actionpack (>= 5.0)
|
||||
actionview (>= 5.0)
|
||||
activerecord (>= 5.0)
|
||||
datetime_picker_rails (~> 0.0.7)
|
||||
jquery-rails (>= 4.0)
|
||||
kaminari (>= 1.0)
|
||||
momentjs-rails (~> 2.8)
|
||||
sassc-rails (~> 2.1)
|
||||
selectize-rails (~> 0.6)
|
||||
ast (2.4.2)
|
||||
bcrypt (3.1.16)
|
||||
bindex (0.8.1)
|
||||
@@ -77,8 +87,11 @@ GEM
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
coderay (1.1.3)
|
||||
concurrent-ruby (1.1.9)
|
||||
crass (1.0.6)
|
||||
datetime_picker_rails (0.0.7)
|
||||
momentjs-rails (>= 2.8.1)
|
||||
devise (4.8.0)
|
||||
bcrypt (~> 3.0)
|
||||
orm_adapter (~> 0.1)
|
||||
@@ -97,6 +110,22 @@ GEM
|
||||
concurrent-ruby (~> 1.0)
|
||||
jbuilder (2.11.2)
|
||||
activesupport (>= 5.0.0)
|
||||
jquery-rails (4.4.0)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
kaminari (1.2.1)
|
||||
activesupport (>= 4.1.0)
|
||||
kaminari-actionview (= 1.2.1)
|
||||
kaminari-activerecord (= 1.2.1)
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-actionview (1.2.1)
|
||||
actionview
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-activerecord (1.2.1)
|
||||
activerecord
|
||||
kaminari-core (= 1.2.1)
|
||||
kaminari-core (1.2.1)
|
||||
listen (3.6.0)
|
||||
rb-fsevent (~> 0.10, >= 0.10.3)
|
||||
rb-inotify (~> 0.9, >= 0.9.10)
|
||||
@@ -110,6 +139,8 @@ GEM
|
||||
mini_mime (1.1.0)
|
||||
mini_portile2 (2.6.1)
|
||||
minitest (5.14.4)
|
||||
momentjs-rails (2.20.1)
|
||||
railties (>= 3.1)
|
||||
msgpack (1.4.2)
|
||||
nio4r (2.5.8)
|
||||
nokogiri (1.12.1)
|
||||
@@ -120,6 +151,12 @@ GEM
|
||||
parser (3.0.2.0)
|
||||
ast (~> 2.4.1)
|
||||
pg (1.2.3)
|
||||
pry (0.13.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
pry-byebug (3.9.0)
|
||||
byebug (~> 11.0)
|
||||
pry (~> 0.13.0)
|
||||
public_suffix (4.0.6)
|
||||
puma (5.4.0)
|
||||
nio4r (~> 2.0)
|
||||
@@ -215,6 +252,7 @@ GEM
|
||||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
selectize-rails (0.12.6)
|
||||
semantic_range (3.0.0)
|
||||
spring (2.1.1)
|
||||
sprockets (4.0.2)
|
||||
@@ -255,8 +293,8 @@ PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
administrate
|
||||
bootsnap (>= 1.4.4)
|
||||
byebug
|
||||
capybara
|
||||
devise
|
||||
devise-bootstrap-views (~> 1.0)
|
||||
@@ -264,6 +302,7 @@ DEPENDENCIES
|
||||
jbuilder (~> 2.7)
|
||||
listen (~> 3.3)
|
||||
pg (~> 1.1)
|
||||
pry-byebug
|
||||
puma (~> 5.0)
|
||||
rack-mini-profiler (~> 2.0)
|
||||
rails (~> 6.1.4)
|
||||
|
||||
8
app/controllers/admin/admin_users_controller.rb
Normal file
8
app/controllers/admin/admin_users_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
module Admin
|
||||
class AdminUsersController < Admin::ApplicationController
|
||||
def valid_action?(name, resource = resource_class)
|
||||
["edit"].exclude?(name.to_s) && super
|
||||
end
|
||||
end
|
||||
end
|
||||
6
app/controllers/admin/application_controller.rb
Normal file
6
app/controllers/admin/application_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
module Admin
|
||||
class ApplicationController < Administrate::ApplicationController
|
||||
before_action :authenticate_admin_user!
|
||||
end
|
||||
end
|
||||
52
app/dashboards/admin_user_dashboard.rb
Normal file
52
app/dashboards/admin_user_dashboard.rb
Normal file
@@ -0,0 +1,52 @@
|
||||
# frozen_string_literal: true
|
||||
require "administrate/base_dashboard"
|
||||
|
||||
class AdminUserDashboard < Administrate::BaseDashboard
|
||||
# ATTRIBUTE_TYPES
|
||||
# a hash that describes the type of each of the model's fields.
|
||||
#
|
||||
# Each different type represents an Administrate::Field object,
|
||||
# which determines how the attribute is displayed
|
||||
# on pages throughout the dashboard.
|
||||
ATTRIBUTE_TYPES = {
|
||||
id: Field::Number,
|
||||
email: Field::String,
|
||||
created_at: Field::DateTime,
|
||||
updated_at: Field::DateTime,
|
||||
}.freeze
|
||||
|
||||
# COLLECTION_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's index page.
|
||||
#
|
||||
# By default, it's limited to four items to reduce clutter on index pages.
|
||||
# Feel free to add, remove, or rearrange items.
|
||||
COLLECTION_ATTRIBUTES = [:id, :email].freeze
|
||||
|
||||
# SHOW_PAGE_ATTRIBUTES
|
||||
# an array of attributes that will be displayed on the model's show page.
|
||||
SHOW_PAGE_ATTRIBUTES = [:id, :email, :created_at, :updated_at].freeze
|
||||
|
||||
# FORM_ATTRIBUTES
|
||||
# an array of attributes that will be displayed
|
||||
# on the model's form (`new` and `edit`) pages.
|
||||
FORM_ATTRIBUTES = [:email].freeze
|
||||
|
||||
# COLLECTION_FILTERS
|
||||
# a hash that defines filters that can be used while searching via the search
|
||||
# field of the dashboard.
|
||||
#
|
||||
# For example to add an option to search for open resources by typing "open:"
|
||||
# in the search field:
|
||||
#
|
||||
# COLLECTION_FILTERS = {
|
||||
# open: ->(resources) { resources.where(open: true) }
|
||||
# }.freeze
|
||||
COLLECTION_FILTERS = {}.freeze
|
||||
|
||||
# Overwrite this method to customize how admin users are displayed
|
||||
# across all pages of the admin dashboard.
|
||||
#
|
||||
# def display_resource(admin_user)
|
||||
# "AdminUser ##{admin_user.id}"
|
||||
# end
|
||||
end
|
||||
@@ -1,5 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
Rails.application.routes.draw do
|
||||
namespace :admin do
|
||||
resources :admin_users
|
||||
|
||||
root to: "admin_users#index"
|
||||
end
|
||||
|
||||
devise_for :admin_users
|
||||
# For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user