Advertisement
Guest User

Untitled

a guest
Sep 20th, 2011
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class Friendship
  2.  
  3. include Mongoid::Document
  4. include Mongoid::Timestamps
  5.  
  6. field :user_id
  7. field :friend_id
  8. field :created_at, :type => DateTime
  9.  
  10. belongs_to :user
  11. belongs_to :friend, :class_name => 'User'
  12.  
  13.  
  14. end
  15.  
  16. ###
  17.  
  18. class Post
  19. belongs_to :user
  20. end
  21.  
  22. ###
  23.  
  24. class User
  25. has_many :posts
  26. has_many :friendships
  27. has_many :friends, :through => :friendships
  28. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement