neoid-gem / neoid

Extend Ruby on Rails ActiveRecord with Neo4j nodes. Keep RDBMS and utilize the power of Neo4j queries.
MIT License
171 stars 33 forks source link

Example of a self referential relationship #2

Closed matthewford closed 12 years ago

matthewford commented 12 years ago

Hi,

I was wondering what would be the best way to define a self referential relationship neoid, for example:

class User
  has_many :follows
  has_many :followed_users, through: :follows
end

class Follow < ActiveRecord::Base
  belongs_to :user  
  belongs_to :followed_user, :class_name => 'User'  
end
matthewford commented 12 years ago

I'm putting this down to 2:50am coding, because:

  neoidable start_node: :user, end_node: :followed_user, type: :follows

Works just fine. Not sure what I was seeing before (probably put user,user).

elado commented 12 years ago

Glad you've found it working. Keep up the feedbacks.