Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError on Neo4j::Core::Node in development mode #1553

Open
sqpierce opened this issue Jun 5, 2019 · 2 comments
Open

NoMethodError on Neo4j::Core::Node in development mode #1553

sqpierce opened this issue Jun 5, 2019 · 2 comments

Comments

@sqpierce
Copy link

sqpierce commented Jun 5, 2019

neo4j gem version: 9.3.0
neo4j-core version: 8.1.4

I'm having an issue that you appear to have solved back in 2015,

here: #717

and

here: neo4jrb/devise-activegraph#16

The error only happens in development mode, and only when a change is made to files and therefore code is reloaded.

The error message, for example, is NoMethodError - undefined method 'name' for #<Neo4j::Core::Node:0x00007f960c7bc858>

where 'name' is one of the properties on one of our nodes (note that the error can happen equally on properties or relationships):

# this is just a snippet
module BitFarm
  class Lesson
    include Neo4j::ActiveNode
    include Neo4j::Timestamps

    self.mapped_label_name = 'Lesson'

    property :name
  end
end

In trying to figure out why we're having this issue, I can only surmise that it might have something to do with the fact that we are using the neo4j gem within a gem of our own (called 'bit_farm'), which is in turn required by our Rails app.

I've tried various things to attempt to address the issue, including setting up a railtie in bit_farm which calls Neo4j::ActiveNode::Labels::Reloading.reload_models! but this does not do anything, as Neo4j::ActiveNode::Labels::Reloading::MODELS_TO_RELOAD appears to be an empty array at that point.

FWIW this was the railtie:

module BitFarm
  class Railtie < ::Rails::Railtie
    config.to_prepare do
      Neo4j::ActiveNode::Labels::Reloading.reload_models!
    end
  end
end

I am fairly certain that the code in neo4j/lib/neo4j/railtie.rb is being executed before the code in our railtie (not sure if that might be a factor).

I have also tried to explicitly load our Lesson class before the query that throws the error (via Kernel#load) and this also has no effect.

I suspect it comes down to something in lib/neo4j/active_node/labels/reloading.rb such as the WRAPPED_CLASSES, but I'm afraid I don't know how to get our classes invited to that party.

Any help or ideas would be greatly appreciated.

@sqpierce
Copy link
Author

sqpierce commented Sep 3, 2019

Hi, this is still an outstanding issue for us, I wonder if anyone has any thoughts?

Or, perhaps I'm not explaining the problem very well?

@OpenCoderX
Copy link
Contributor

I'm experiencing this also. One aspect to our codebase is that we define one of our neo4j models in a separate gem that we then include in our app. When the rails app first boots everything is good, then If I change any file I get this error. For example, I can add an empty line to an unrelated class, reload the page and this error appears. I tried to look into the rails autoloading system but it seems there is no easy way to log reloading errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants