-
Notifications
You must be signed in to change notification settings - Fork 272
Open
Description
ActiveGraph relies on a Rails 3.x method for cache clearing: before_remove_const.
We are running with the gem in a Rails 7 app. So the method is never called, and as such, we must restart our development server anytime we make a change to a node instance method.
FWIW: There is a Rails guide for upgrading it to Zeitwerk (the latest reloading library).
In our application, we monkey patch this in the initializer. It's one-to-one re-write of the current before_remove_const method. It's not perfect: we must add each ActiveGraph node (relationships are OK as-is), but it works:
Code example (initializers/neo4j.rb)
unless Rails.application.config.cache_classes
node_classes = [
"StateSecret",
"LaunchCode",
"Bribe",
"User"
]
node_classes.each do |node_class|
Rails.autoloaders.main.on_unload(node_class) do |klass, _abspath|
klass.associations.each_value(&:queue_model_refresh!)
klass::MODELS_FOR_LABELS_CACHE.clear
klass::WRAPPED_CLASSES.each { |c| klass::MODELS_TO_RELOAD << c.name }
klass::WRAPPED_CLASSES.clear
end
end
endRuntime information:
Neo4j database version: neo4j:4.0.9-community
activegraph gem version: 10.2.0.beta.1
rails gem version: 7.0.3
Metadata
Metadata
Assignees
Labels
No labels