Skip to content

Instantly share code, notes, and snippets.

@rromanchuk
Created October 31, 2018 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rromanchuk/486f6fbd4fec28c8fa69d36220795343 to your computer and use it in GitHub Desktop.
Save rromanchuk/486f6fbd4fec28c8fa69d36220795343 to your computer and use it in GitHub Desktop.
if Rails.application.config.action_mailer.show_previews
Rails::MailersController.class_eval do
include AdminWebAuthenticatable
end
end
module AdminWebAuthenticatable
extend ActiveSupport::Concern
included do
before_action :require_user!
helper_method :current_user
helper_method :current_admin
rescue_from NotAuthorizedException, with: -> { redirect_to root_path }
end
# Truncated
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment