我在以下代码application controller
:
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
Rails.logger.debug ex
do_stuff(ex)
end
我想将其移动到模块中,然后:
class ApplicationController < ActionController::Base
include 'module'
...
现在我的模块看起来像:
# lib/exception_mailer.rb
require 'action_mailer'
require 'active_support'
module ExceptionMailer
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
...
我得到: undefined method 'rescue_from' for ExceptionMailer:Module
我已经在Google上搜索“如何在模块中包含rescue_from?” -而且我还是有些失落。
module Exceptionailer
# http://api.rubyonrails.org/classes/ActiveSupport/Concern.html
extend ActiveSupport::Concern
included do
rescue_from Exception do |ex|
...
end
end
end
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句