I have this code in application controller
:
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
Rails.logger.debug ex
do_stuff(ex)
end
I want to move this into a module and then:
class ApplicationController < ActionController::Base
include 'module'
...
Right now my module looks like:
# lib/exception_mailer.rb
require 'action_mailer'
require 'active_support'
module ExceptionMailer
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
...
And I am getting: undefined method 'rescue_from' for ExceptionMailer:Module
I've googled 'how do i include rescue_from in a module?' -- and I'm still a little lost.
module Exceptionailer
# http://api.rubyonrails.org/classes/ActiveSupport/Concern.html
extend ActiveSupport::Concern
included do
rescue_from Exception do |ex|
...
end
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With