Repository navigation
How to setup maintenance tasks with a custom controller? #646
Answered
by
etiennebarrie
CodeGradox
asked this question in
Q&A
|
Hi! I want to try out maintenance tasks, but before I proceed, I need to know how to overwrite the controller provided by the engine. I'd like to add authorization to only allow admins to access the maintenance page. |
Answered by
etiennebarrie
Jun 9, 2022
Replies: 2 comments
|
One thing that can be done is to wrap the route in a constraint, like it's usually done with Sidekiq for example: https://github.com/mperham/sidekiq/wiki/Monitoring#authentication You can also directly access # config/initializers/maintenance_tasks.rb
Rails.application.config.to_prepare do
MaintenanceTasks::ApplicationController.class_eval do
include Authentication
before_action :authenticate
end
end |
0 replies
Answer selected by
etiennebarrie
|
I tested with a custom constraint class, and it works really well! Thanks for the help 🧡 |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One thing that can be done is to wrap the route in a constraint, like it's usually done with Sidekiq for example: https://github.com/mperham/sidekiq/wiki/Monitoring#authentication
You can also directly access
MaintenanceTasks::ApplicationControllerand use abefore_actionthere if you want, e.g.: