diff --git a/app/models/bid.rb b/app/models/bid.rb index fd389c15f..e58e640a0 100644 --- a/app/models/bid.rb +++ b/app/models/bid.rb @@ -29,6 +29,7 @@ class Bid < ActiveRecord::Base has_many :courses, :through => :homework_for_courses, :source => :project has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy has_many :join_in_contests, :dependent => :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy # has_many :fork_homework, :class_name => 'Bid', :conditions => "#{Bid.table_name}.parent_id = #{id}" diff --git a/app/models/contest.rb b/app/models/contest.rb index edc252574..c3eea7e74 100644 --- a/app/models/contest.rb +++ b/app/models/contest.rb @@ -12,6 +12,7 @@ class Contest < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy has_many :join_in_competitions, foreign_key: 'competition_id', :dependent => :destroy has_many :join_in_contests, class_name: 'JoinInCompetition', foreign_key: 'competition_id', :dependent => :destroy + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy diff --git a/app/models/issue.rb b/app/models/issue.rb index 43bc6537d..b69ac246c 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -45,7 +45,8 @@ class Issue < ActiveRecord::Base # added by fq has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy - # end + # end + has_many :praise_tread, as: :praise_tread_object, dependent: :destroy acts_as_nested_set :scope => 'root_id', :dependent => :destroy diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb index 901a31660..c27e1fc9f 100644 --- a/app/models/praise_tread.rb +++ b/app/models/praise_tread.rb @@ -1,4 +1,6 @@ class PraiseTread < ActiveRecord::Base attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread + belongs_to :user + belongs_to :praise_tread_object, polymorphic: true end