diff --git a/config/initializers/delayed_web.rb b/config/initializers/delayed_web.rb index ec58ef646..9150860a1 100644 --- a/config/initializers/delayed_web.rb +++ b/config/initializers/delayed_web.rb @@ -6,6 +6,10 @@ Delayed::Web::ApplicationController.class_eval do include FlashI18n + rescue_from ActiveRecord::RecordNotFound do + redirect_to root_url, notice: t(:notice, scope: 'delayed/web.flashes.jobs.not_found') + end + before_action :require_admin def admin_request? diff --git a/config/locales/delayed_web.en-GB.yml b/config/locales/delayed_web.en-GB.yml index d00192284..50d43dba4 100644 --- a/config/locales/delayed_web.en-GB.yml +++ b/config/locales/delayed_web.en-GB.yml @@ -34,3 +34,5 @@ en-GB: destroyed: alert: 'Job cannot be deleted because it is already %{status}' notice: 'Job destroyed' + not_found: + notice: 'Job not found'