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: