Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## DB Attributes for discussions table
- title
- body
- discussable_id
- discussable_type
- type
- created_at
- updated_at
- ## Main Discussion model
- class Discussion < ActiveRecord::Base
- belongs_to :user
- belongs_to :discussable, :polymorphic=>true
- has_many :discussion_replies, :as=>:discussable
- end
- ## Subtypes of discussions, with a reference to the parent discussion as their discussable
- class DiscussionReply < Discussion; end;
- class Critique < Discussion; end;
- class Event < Discussion; end;
- ## Parents of main discussion topics
- class Project < ActiveRecord::Base
- has_many :discussions, :as=>:discussable
- has_many :events, :as=>:discussable
- end
- class Group < ActiveRecord::Base
- has_many :discussions, :as=>:discussable
- has_many :critiques, :as=>:discussable
- end
Add Comment
Please, Sign In to add comment