socialforge/app/models/apply_resource.rb

20 lines
762 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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