7
Ben application controller
bu kodu vardır:ActiveSupport'un rescue_from yöntemini nasıl gerektirebilirim?
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
Rails.logger.debug ex
do_stuff(ex)
end
Sonra bir modül ve içine bu hareket etmek istiyorum:
# lib/exception_mailer.rb
require 'action_mailer'
require 'active_support'
module ExceptionMailer
# Method to capture and handle all exceptions
rescue_from Exception do |ex|
...
Ve I:
class ApplicationController < ActionController::Base
include 'module'
...
Şu anda benim modül benziyor alıyorum: undefined method 'rescue_from' for ExceptionMailer:Module
Ben googled ettik 'Rescue_from'u bir modülde nasıl eklerim?' - ve hala biraz kayboldum.
Bu bağlantı size yardımcı olabilir. http://apidock.com/rails/ActiveSupport/Rescuable/ClassMethods/rescue_from – Joel
Sanırım ActiveSupport :: Concern'i genişletmek ve 'do do 'blokunu kullanarak bir çözüm buldum. Raylar benim gemimin bir bağımlılığıdır. Şu anda herhangi bir şeye ihtiyacım yok. –