我如何需要ActiveSupport的rescue_from方法?
我在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
- ActiveSupport :: JSON.decode无法正确处理文字换行符
- Activesupport / Multi json:“无法识别您的适配器规范”
- 您如何知道何时使用XML解析器以及何时使用ActiveResource?
- rails activesupport通知 – 错误的db运行时值
- ActiveSupport中mattr_accessor和cattr_accessor之间的区别?
- 你如何处理ActiveSupport :: JSON和JSON gem之间的冲突?
- 如何使用Active Support核心扩展?
- Rails time_ago_in_words产生错误的输出
- 覆盖ActiveSupport :: Concern模块中的方法,这些方法由同一模块中的类方法定义