1

I have an application which uses Neo4j to back-end one model and PostgreSQL to back-end all the other models. Here is the Neo4j model:

class Concept
  include Neo4j::ActiveNode
  property :name

  def references
    Reference.where(concept_uuid: uuid)
  end
end

and here is an ActiveRecord model. The references table has a content_uuid on it:

class Reference < ActiveRecord::Base
  def concept
    Concept.where(uuid: concept_uuid).first
  end
end

This works, and I can do things like Reference.first.concept and Concept.first.references without incident. I wish, though, that I could do something simple like this instead:

class Reference < ActiveRecord::Base
  belongs_to :concepts
end

class Concept < ActiveRecord::Base
  include Neo4j::ActiveNode
  property :name
  has_many :references
end

because then I'd get things like Concept.first.references << new_reference out of the box. Does any such functionality exist?

1 Answers1

2

I replied on the Github issue but I'll post here just in case anyone comes across it!

At the moment, we're not planning on building this functionality into the ActiveNode module. I definitely could see how a new module and class could be created to handle this sort of thing, but we'd need to plan it out and figure just how far to go. This gem has a goal of being a standalone OGM and since providing ActiveRecord interoperability isn't the goal, I fear that trying to tack on behavior to aid in that pursuit might result in crappy implementations with poor support on our end.

You might want to check out the Neoid gem, its focus is exactly this and if/when its rebuild finishes, I think it will do a great job of it.

subvertallchris
  • 5,282
  • 2
  • 25
  • 43