删除作品时,删除作品的点赞数

This commit is contained in:
sw 2015-07-17 14:48:20 +08:00
parent 666539a4cc
commit 1f6ed64e54
1 changed files with 6 additions and 0 deletions

View File

@ -9,5 +9,11 @@ class StudentWork < ActiveRecord::Base
belongs_to :project
has_one :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