メーラー機能を含まないページでRadiant メーラー拡張機能 を実行すると問題が発生します。SystemStackError in SiteController#show_page
問題を引き起こすモジュールがあることがわかりました:
Module MailerProcess
include RecaptchaMailer
def self.included(base)
base.class_eval {
alias_method_chain :process, :mailer
attr_accessor :last_mail
}
end
def process_with_mailer(request, response)
# If configured to do so, receive and process the mailer POST
if Radiant::Config['mailer.post_to_page?'] && ...
# here process_mail from RecaptchaMailer called - works fine
end
process_without_mailer(request, response)
end
end
そして、process_without_mailer
これが私を完全に混乱させるものです-そのような定義はありません。この方法では、実際にはログに多くの「SHOW TABLES」が発生し、最終的に例外が発生します。このメソッドは多かれ少なかれ Rails の一部であると思われます。actionpack-2.3.18/lib/action_controller/filters.rb
( process_without_filters
)、rails-4.0.0/guides/source/active_support_core_extensions.md
( process_without_stringified_params
) などに同じ呼び出しがあるためです。これらのメソッドにも定義はありません。
したがって、2 つの質問があります。
- ページの読み込み中
process_with_mailer
に呼び出されるのはなぜですか? - 背後にある魔法は何
process_without_mailer
ですか?
更新:
わかりました、メソッドをコメントアウトすると、process_with_mailer
起動時にエラーが発生します:
/home/sab/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-2.3.18/lib/active_support/core_ext/module/aliasing.rb:34:in `alias_method': undefined method `process_with_mailer' for class `Page' (NameError)
from /home/sab/.rvm/gems/ruby-1.9.3-p448/gems/activesupport-2.3.18/lib/active_support/core_ext/module/aliasing.rb:34:in `alias_method_chain'
from /home/sab/_work/radiant-cms/vendor/extensions/mailer/lib/mailer_process.rb:6:in `block in included'
from /home/sab/_work/radiant-cms/vendor/extensions/mailer/lib/mailer_process.rb:5:in `class_eval'
そのため、ページが読み込まれるたびにメソッドが呼び出される可能性alias_method_chain
がありますが、メカニズムは私にはわかりません。ActiveSuppor のドキュメントをいくつか見つけました。
UPD2 よく私は終わった
- Ruby on Rails: alias_method_chain を読んで、それは正確に何をしますか?
- コメントアウト
process_with_mailer
とalias_method_chain
. その構成ではメールを送信するので、それは受け入れられます。私はまだ知りたいのですが、著者の一般的な考えは何でしたか.