pgfqe6ch8/app/models/apply_resource.rb

20 lines
762 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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