У меня есть этот код в 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
Я погуглил: «Как мне включить Rescue_from в модуль?» -- И я все еще немного потерян.
extend ActiveSupport::Concern
и использующее блокincluded do
. Rails является зависимостью моего драгоценного камня. В настоящее время мне не нужно ничего требовать. - person Eric Francis   schedule 26.09.2014