Skip to content

Commit 5a6ddc0

Browse files
committed
re-add rails_admin
1 parent cfa6ed7 commit 5a6ddc0

File tree

8 files changed

+1913
-1476
lines changed

8 files changed

+1913
-1476
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ gem 'redis'
9696
gem 'csv'
9797

9898
# Admin
99-
# gem 'rails_admin', '~> 2.2'
99+
gem 'rails_admin'
100100

101101
# Tech debt & hacks
102102
gem 'binding_of_caller' # see has_changelog.rb

Gemfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ GEM
104104
globalid (>= 0.3.6)
105105
activemodel (6.1.7.2)
106106
activesupport (= 6.1.7.2)
107+
activemodel-serializers-xml (1.0.2)
108+
activemodel (> 5.x)
109+
activesupport (> 5.x)
110+
builder (~> 3.1)
107111
activerecord (6.1.7.2)
108112
activemodel (= 6.1.7.2)
109113
activesupport (= 6.1.7.2)
@@ -1462,6 +1466,7 @@ GEM
14621466
multi_json (1.15.0)
14631467
multipart-post (2.3.0)
14641468
mustache (1.1.1)
1469+
nested_form (0.3.2)
14651470
net-imap (0.3.4)
14661471
date
14671472
net-protocol
@@ -1541,6 +1546,12 @@ GEM
15411546
rails (>= 3.2)
15421547
rails-ujs (0.1.0)
15431548
railties (>= 3.1)
1549+
rails_admin (3.1.1)
1550+
activemodel-serializers-xml (>= 1.0)
1551+
kaminari (>= 0.14, < 2.0)
1552+
nested_form (~> 0.3)
1553+
rails (>= 6.0, < 8)
1554+
turbo-rails (~> 1.0)
15441555
rails_gravatar (1.0.4)
15451556
actionview
15461557
railties (6.1.7.2)
@@ -1640,6 +1651,10 @@ GEM
16401651
timeago_js (3.0.2.2)
16411652
timeout (0.3.1)
16421653
tribute (3.6.0.0)
1654+
turbo-rails (1.3.3)
1655+
actionpack (>= 6.0.0)
1656+
activejob (>= 6.0.0)
1657+
railties (>= 6.0.0)
16431658
tzinfo (2.0.6)
16441659
concurrent-ruby (~> 1.0)
16451660
uglifier (4.2.0)
@@ -1724,6 +1739,7 @@ DEPENDENCIES
17241739
rails (~> 6.1)
17251740
rails-jquery-autocomplete
17261741
rails-ujs
1742+
rails_admin
17271743
react-rails
17281744
redcarpet
17291745
redis
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import "rails_admin/src/rails_admin/base";
2+
import "../stylesheets/rails_admin.scss";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "rails_admin/src/rails_admin/styles/base";

config/initializers/rails_admin.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
RailsAdmin.config do |config|
2+
config.asset_source = :webpacker
3+
4+
### Popular gems integration
5+
6+
## == Devise ==
7+
# config.authenticate_with do
8+
# warden.authenticate! scope: :user
9+
# end
10+
# config.current_user_method(&:current_user)
11+
12+
## == Cancan ==
13+
# config.authorize_with :cancan
14+
15+
## == Pundit ==
16+
# config.authorize_with :pundit
17+
18+
## == PaperTrail ==
19+
# config.audit_with :paper_trail, 'User', 'PaperTrail::Version' # PaperTrail >= 3.0.0
20+
21+
### More at https://github.com/railsadminteam/rails_admin/wiki/Base-configuration
22+
23+
## == Gravatar integration ==
24+
## To disable Gravatar integration in Navigation Bar set to false
25+
# config.show_gravatar = true
26+
27+
config.actions do
28+
dashboard # mandatory
29+
index # mandatory
30+
new
31+
export
32+
bulk_delete
33+
show
34+
edit
35+
delete
36+
show_in_app
37+
38+
## With an audit adapter, you can add:
39+
# history_index
40+
# history_show
41+
end
42+
43+
config.authorize_with do
44+
redirect_to main_app.root_path unless user_signed_in? && current_user.site_administrator?
45+
end
46+
47+
config.included_models = [
48+
"User",
49+
"ApiKey",
50+
"BillingPlan",
51+
"ImageUpload",
52+
"Referral",
53+
"Document",
54+
] + Rails.application.config.content_types[:all].map(&:name)
55+
# Todo whitelist the fields we want to show for each model
56+
# config.model 'User' do
57+
# list do
58+
# field :name
59+
# field :created_at
60+
# end
61+
# end
62+
end

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@
285285
get '/notifications', to: 'admin#notifications'
286286
post '/perform_unsubscribe', to: 'admin#perform_unsubscribe', as: :perform_unsubscribe
287287
end
288-
# mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
288+
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
289289
end
290290

291291
# Fancy shmancy informative pages

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
1111
"pluralize": "^8.0.0",
1212
"prop-types": "^15.7.2",
13+
"rails_admin": "3.1.1",
1314
"react": "^16.14.0",
1415
"react-dom": "^16.14.0",
1516
"react-simple-format": "^0.3.0",
@@ -24,6 +25,7 @@
2425
"fsevents": "^2.3.2"
2526
},
2627
"resolutions": {
27-
"chokidar": "^3.4.0"
28+
"chokidar": "^3.4.0",
29+
"rails_admin/@fortawesome/fontawesome-free": "^5.15.0"
2830
}
2931
}

0 commit comments

Comments
 (0)