Wrap text
|
|
# suggestee_id
# suggestor_id
# suggested_id
# suggested_type
class Suggestion < AR::Base
belongs_to :suggested, :polymorhpic => true
belongs_to :suggestor, :class => 'User'
belongs_to :suggestee, :class => 'User'
end
class Item < AR::Base
has_many :suggestions, :as => :suggestion
has_many :suggstors, :through => :suggestions
has_many :suggestees, :through => :suggestions
end
class User < AR::Base
has_many :suggestions, :foreign_key => 'suggestor_id'
has_many :suggestables, :through => :suggestions
has_many :personal_suggestions, :foreign_key => 'suggestee_id'
has_many :suggested, :through => :personal_suggestions
end
|