socialforge/app/models/apply_resource.rb

20 lines
762 B
Ruby
Raw Normal View History

2016-05-18 14:49:13 +08:00
class ApplyResource < ActiveRecord::Base
# status1. 等待回复 2.审核通过 3.已拒绝
2016-05-18 14:49:13 +08:00
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
2016-05-19 11:32:58 +08:00
self.course_messages << CourseMessage.new(:user_id => self.apply_user_id, :course_id => -1, :viewed => false, :status => 0, )
2016-05-18 14:49:13 +08:00
# REDO:发送邮件
# Mailer.run.apply_for_resource_request(self.container_id, User.current)
end
2016-05-19 11:32:58 +08:00
def find_attachment attachment_id
Attachment.find(attachment_id)
end
2016-05-18 14:49:13 +08:00
end