7
나는 application controller
에이 코드를 가지고 :어떻게 ActiveSupport의 rescue_from 메소드가 필요합니까?
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
Rails.logger.debug ex
do_stuff(ex)
end
그때 모듈과이 점을 이동하려는 :
# lib/exception_mailer.rb
require 'action_mailer'
require 'active_support'
module ExceptionMailer
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
...
그리고 I :
이class ApplicationController < ActionController::Base
include 'module'
...
지금 내 모듈의 모습 오전 점점 : undefined method 'rescue_from' for ExceptionMailer:Module
내가 봤 거든 '어떻게 rescue_from을 모듈에 포함시킬 수 있습니까?' - 나는 아직도 조금 길을 잃어 버렸다.
이 링크를 클릭하면 도움이 될 것입니다. http://apidock.com/rails/ActiveSupport/Rescuable/ClassMethods/rescue_from – Joel
'ActiveSupport :: Concern 확장'및 '포함 된 do'블록을 사용하여 해결책을 찾은 것 같습니다. Rails는 내 보석의 의존성입니다. 나는 현재 어떤 것도 요구할 필요가 없다. –