Skip to content

Instantly share code, notes, and snippets.

@derekbrameyer
Created June 21, 2010 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save derekbrameyer/6988ae9a1b50de1108c1 to your computer and use it in GitHub Desktop.
Save derekbrameyer/6988ae9a1b50de1108c1 to your computer and use it in GitHub Desktop.
class Relationship
include Mongoid::Document
named_scope :following, where(:rel_type => "following")
named_scope :followed_by, where(:rel_type => "followed_by")
named_scope :friends_with, where(:rel_type => "friends_with")
# rel_type can be "following" "followed_by" or "friends_with"
field :rel_type, :type => String
field :rel_user, :class_name => "User"
#has_one_related :rel_user, :class_name => "User"
embedded_in :user, :inverse_of => :relationships
def establish_relationship
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment