#学生提交作品表 class StudentWork < ActiveRecord::Base attr_accessible :name, :description, :homework_common_id, :user_id, :final_score, :teacher_score, :student_score, :teaching_asistant_score, :project_id belongs_to :homework_common belongs_to :user has_many :student_works_evaluation_distributions, :dependent => :destroy has_many :student_works_scores, :dependent => :destroy belongs_to :project has_many :student_work_test before_destroy :delete_praise acts_as_attachable def delete_praise PraiseTread.where("praise_tread_object_id = #{self.id} AND praise_tread_object_type = 'StudentWork'").destroy_all end end