From 8384eff7f2ca9992df4f41c8ba0e045bfd05b622 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 29 Apr 2015 23:17:24 +0800 Subject: [PATCH 1/2] =?UTF-8?q?delayed=5Fjob=E6=9D=A1=E4=BB=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index a930b5467..d0a928bfa 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -33,7 +33,7 @@ class Mailer < ActionMailer::Base @target = cls end def method_missing(name, *args, &block) - if Setting.delayjob_enabled && Object.const_defined?('Delayed') + if Setting.delayjob_enabled? && Object.const_defined?('Delayed') @target.delay.send(name, *args, &block) else @target.send(name, *args, &block).deliver From dbccf9034dc839da1540d305b0f995146f2d4f55 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 30 Apr 2015 10:31:06 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/mailer.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/models/mailer.rb b/app/models/mailer.rb index d0a928bfa..7ccee1932 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -143,7 +143,7 @@ class Mailer < ActionMailer::Base @course_journal_messages,@user_journal_messages,@forums,@memos,@attachments,@bids].any? {|o| !o.empty? } - binding.pry if Rails.env.development? + mylogger.debug "Sent activity mail : #{user.mail} - #{has_content}" #有内容才发,没有不发 mail :to => user.mail,:subject => subject if has_content end @@ -818,11 +818,12 @@ class Mailer < ActionMailer::Base end set_language_if_valid @initial_language - super headers do |format| + m = super headers do |format| format.text format.html unless Setting.plain_text_mail? end - + mylogger.debug "Sent a mail from #{m.from} to [#{m.to},#{m.cc}, #{m.bcc if Setting.bcc_recipients?}] subject: #{m.subject}" + m end def initialize(*args) @@ -877,7 +878,11 @@ class Mailer < ActionMailer::Base end def mylogger - Rails.logger + if Setting.delayjob_enabled? + Delayed::Worker.logger + else + Rails.logger + end end def add_attachments(obj)