Skip to content

How to setup maintenance tasks with a custom controller? #646

Answered by etiennebarrie
CodeGradox asked this question in Q&A
Discussion options

You must be logged in to vote

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::ApplicationController and use a before_action there if you want, e.g.:

# config/initializers/maintenance_tasks.rb
Rails.application.config.to_prepare do
  MaintenanceTasks::ApplicationController.class_eval do
    include Authentication
    before_action :authenticate
  end
end

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by etiennebarrie
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants