From cf9455e465545034b87ffa8b5e8323e869c2483f Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 17 Jun 2015 16:25:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E5=B8=83=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=B7=BB=E5=8A=A0=E5=88=B0=E9=82=AE=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 5 +++++ app/models/mailer.rb | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 06bc1fd38..648108e47 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -3,6 +3,7 @@ class HomeworkCommonController < ApplicationController before_filter :find_course, :only => [:index,:new,:create] before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy] before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment] + after_create :send_mail def index homeworks = @course.homework_commons.order("created_at desc") @@ -183,6 +184,10 @@ class HomeworkCommonController < ApplicationController end end + def send_mail + Mailer.run.homework_added(self) + end + private #获取课程 def find_course diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 729da17c3..8d027da12 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -517,6 +517,15 @@ class Mailer < ActionMailer::Base end end + # Builds a Mail::Message object used to email recipients of a course when an homework are posted. + # + # Example: + # attachments_added(attachments) => Mail::Message object + # Mailer.attachments_added(attachments).deliver => sends an email to the project's recipients + def homework_added + + end + # Builds a Mail::Message object used to email recipients of a news' project when a news item is added. # # Example: