Rails: How do I require ActiveSupport's rescue_from method?

Eric Francis

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.

Eric Francis
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] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Rails:我如何需要ActiveSupport的rescue_from方法?

来自分类Dev

我如何需要ActiveSupport的rescue_from方法?

来自分类Dev

Rails rescue_from停止执行流程

来自分类Dev

如何在Rails rescue_from语句中重新引发Ruby异常?

来自分类Dev

如何在Rails rescue_from语句中重新引发Ruby异常?

来自分类Dev

How do I access a jQuery plugin variable from within method?

来自分类Dev

Rails 5 生产错误 activesupport

来自分类Dev

Rspec/Rails: uninitialized constant ActiveSupport::Autoload (NameError)

来自分类Dev

ActiveSupport ::关注和alias_method_chain

来自分类Dev

How do I create a link to a pdf file with rails?

来自分类Dev

Rescue_from 不起作用

来自分类Dev

How do I mock a method call inside the method I want to test using NUnit?

来自分类Dev

How do I pass async method as Action or Func

来自分类Dev

How do I use a Codeigniter method within my own function?

来自分类Dev

How to skip a method in a rails model when invoked from different controllers

来自分类Dev

How do I open up a random url from a list of url's in a new time each time it is clicked?

来自分类Dev

Rails5-ruby 2.2.3 // ActiveSupport :: TimeZone如何更改?

来自分类Dev

Rspec / Rails:未初始化的常量ActiveSupport :: Autoload(NameError)

来自分类Dev

Rails ActiveSupport :: TimeWithZone as_json日期格式问题

来自分类Dev

Rails安装失败:activesupport需要Ruby版本> = 2.2.2

来自分类Dev

带有Rails Sortable的ActiveSupport :: MessageVerifier :: InvalidSignature错误

来自分类Dev

非启动Rails 5.2应用-ActiveSupport :: MessageEncryptor :: InvalidMessage

来自分类Dev

Rails 4 gem-ActiveSupport-方法已定义

来自分类Dev

How do I give a list dynamically without hardcoding to MongoDB's $in?

来自分类Dev

How do I use matplotlib's event handing inside wxPython?

来自分类Dev

How do I apply decorators to a superclass's methods?

来自分类Dev

How do I receive files via Python's BaseHTTPRequestHandler class?

来自分类Dev

How do I programmatically disable Hazelcast client's logging?

来自分类Dev

How do I get the computer's current language in Go?

Related 相关文章

  1. 1

    Rails:我如何需要ActiveSupport的rescue_from方法?

  2. 2

    我如何需要ActiveSupport的rescue_from方法?

  3. 3

    Rails rescue_from停止执行流程

  4. 4

    如何在Rails rescue_from语句中重新引发Ruby异常?

  5. 5

    如何在Rails rescue_from语句中重新引发Ruby异常?

  6. 6

    How do I access a jQuery plugin variable from within method?

  7. 7

    Rails 5 生产错误 activesupport

  8. 8

    Rspec/Rails: uninitialized constant ActiveSupport::Autoload (NameError)

  9. 9

    ActiveSupport ::关注和alias_method_chain

  10. 10

    How do I create a link to a pdf file with rails?

  11. 11

    Rescue_from 不起作用

  12. 12

    How do I mock a method call inside the method I want to test using NUnit?

  13. 13

    How do I pass async method as Action or Func

  14. 14

    How do I use a Codeigniter method within my own function?

  15. 15

    How to skip a method in a rails model when invoked from different controllers

  16. 16

    How do I open up a random url from a list of url's in a new time each time it is clicked?

  17. 17

    Rails5-ruby 2.2.3 // ActiveSupport :: TimeZone如何更改?

  18. 18

    Rspec / Rails:未初始化的常量ActiveSupport :: Autoload(NameError)

  19. 19

    Rails ActiveSupport :: TimeWithZone as_json日期格式问题

  20. 20

    Rails安装失败:activesupport需要Ruby版本> = 2.2.2

  21. 21

    带有Rails Sortable的ActiveSupport :: MessageVerifier :: InvalidSignature错误

  22. 22

    非启动Rails 5.2应用-ActiveSupport :: MessageEncryptor :: InvalidMessage

  23. 23

    Rails 4 gem-ActiveSupport-方法已定义

  24. 24

    How do I give a list dynamically without hardcoding to MongoDB's $in?

  25. 25

    How do I use matplotlib's event handing inside wxPython?

  26. 26

    How do I apply decorators to a superclass's methods?

  27. 27

    How do I receive files via Python's BaseHTTPRequestHandler class?

  28. 28

    How do I programmatically disable Hazelcast client's logging?

  29. 29

    How do I get the computer's current language in Go?

热门标签

归档