socialforge/app/models/apply_resource.rb

15 lines
635 B
Ruby

class ApplyResource < ActiveRecord::Base
attr_accessible :attachment_id, :status, :user_id, :container_type, :container_id, :apply_user_id, :content
belongs_to :user
belongs_to :attachment
has_many :course_messages, :class_name => 'CourseMessage', :as => :course_message, :dependent => :destroy
after_create :act_as_apply_resource_message
def act_as_apply_resource_message
self.course_messages << CourseMessage.new(:user_id => self.user_id, :course_id => self.container_id, :viewed => false, :status => 5)
# REDO:发送邮件
# Mailer.run.apply_for_resource_request(self.container_id, User.current)
end
end