From f9a411ae6018aa70ae2610dce20f4e4063e70d1c Mon Sep 17 00:00:00 2001 From: bohung Date: Mon, 30 Nov 2020 23:59:51 +0800 Subject: [PATCH] Fix bug. --- app/views/admin/e_paper_criterias/emailer.html.erb | 3 ++- lib/tasks/e_paper_tasks.rake | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/admin/e_paper_criterias/emailer.html.erb b/app/views/admin/e_paper_criterias/emailer.html.erb index 52e59fd..5fa3393 100644 --- a/app/views/admin/e_paper_criterias/emailer.html.erb +++ b/app/views/admin/e_paper_criterias/emailer.html.erb @@ -1,4 +1,5 @@ -<% paper = @data["paper"] %> +<% paper = PaperCriteria.find(@data["paper_id"]) rescue nil %> +<% paper = @data["paper"] if paper.nil? && @data["paper"] != nil %> <% page = @data["page"] %> <% siteurl = @data["siteurl"] %> <% papers_data = @data["papers_data"] %> diff --git a/lib/tasks/e_paper_tasks.rake b/lib/tasks/e_paper_tasks.rake index 9b32fbf..982f048 100644 --- a/lib/tasks/e_paper_tasks.rake +++ b/lib/tasks/e_paper_tasks.rake @@ -23,7 +23,7 @@ namespace :epaper do Thread.new do tmp = [] emails_valid.each_slice(mail_limit).each do |slice_emails| - email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper" => paper, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => slice_emails) + email = Email.new(:mail_subject => paper.sending_title, :mail_lang => args[:locale], :template => "admin/e_paper_criterias/emailer", :template_data => {"paper_id" => paper.id, "page" => "http://" + domain + page, "siteurl" => "http://" + domain, "papers_data" => papers_data }, :mail_to => slice_emails.join(",")) begin email.save email.deliver