Skip to content

Instantly share code, notes, and snippets.

@tjackiw
Created December 18, 2012 23:01
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 tjackiw/4332914 to your computer and use it in GitHub Desktop.
Save tjackiw/4332914 to your computer and use it in GitHub Desktop.
Using a Graph Database with Ruby. Part II: Integration
class Friendship < ActiveRecord::Base
include Neoid::Relationship
attr_accessible :friend
belongs_to :user
belongs_to :friend, class_name: User
neoidable do |c|
c.relationship start_node: :user, end_node: :friend, type: :friends
end
class << self
def create_both(user, friend)
user.friends.create(friend: friend)
friend.friends.create(friend: user)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment