You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pgfqe6ch8/app/models/apply_resource.rb

20 lines
762 B

6 years ago
class ApplyResource < ActiveRecord::Base
# status1. 等待回复 2.审核通过 3.已拒绝
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.apply_user_id, :course_id => -1, :viewed => false, :status => 0, )
# REDO:发送邮件
# Mailer.run.apply_for_resource_request(self.container_id, User.current)
end
def find_attachment attachment_id
Attachment.find(attachment_id)
end
end