diff --git a/app/controllers/admin/e_paper_criterias_controller.rb b/app/controllers/admin/e_paper_criterias_controller.rb index de4ac13..dbd710b 100644 --- a/app/controllers/admin/e_paper_criterias_controller.rb +++ b/app/controllers/admin/e_paper_criterias_controller.rb @@ -56,7 +56,7 @@ def initialize def send_newsletter Orbit::Application.load_tasks - rake = Rake::Task['epaper:send_email'].execute(OpenStruct.new({:paper_criteria_id => params[:id], :domain => request.host_with_port, :locale => I18n.locale})) + rake = Rake::Task['epaper:send_email'].execute(OpenStruct.new({:paper_criteria_id => params[:id], :domain => request.host_with_port, :locale => I18n.locale.to_s})) # rake = Rake::Task['epaper:send_email'].invoke([params[:id], request.host_with_port]) paper = PaperCriteria.find(params[:id]) rescue nil if !paper.nil? && paper.invalid_emails.blank? diff --git a/lib/tasks/e_paper_tasks.rake b/lib/tasks/e_paper_tasks.rake index 738841f..9b32fbf 100644 --- a/lib/tasks/e_paper_tasks.rake +++ b/lib/tasks/e_paper_tasks.rake @@ -25,6 +25,7 @@ namespace :epaper do 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) begin + email.save email.deliver puts "Sending #{slice_emails.count} emails" rescue => e