赞踩关联关系

This commit is contained in:
yanxd 2014-04-22 08:56:26 +08:00
parent 4de9f959ac
commit 0791c35df1
4 changed files with 6 additions and 1 deletions

View File

@ -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}"

View File

@ -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

View File

@ -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

View File

@ -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