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

generators enhancements and fixes #1716

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/active_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
loader.ignore(File.expand_path('rails', __dir__))
loader.ignore(File.expand_path('active_graph/railtie.rb', __dir__))
loader.inflector.inflect("ansi" => "ANSI")
module ActiveGraph
end
loader.setup
# loader.eager_load

Expand Down
12 changes: 7 additions & 5 deletions lib/active_graph/railtie.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# Need the action_dispatch railtie to have action_dispatch.rescue_responses initialized correctly
require 'action_dispatch/railtie'
require 'rails/generators'
require 'rails/generators/active_model'
require 'rails/generators/named_base'
require 'rails/railtie'
require File.expand_path('../rails/generators/migration_helper.rb', __dir__)
Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute
require 'active_graph'

module ActiveGraph
Expand Down Expand Up @@ -44,6 +39,13 @@ def empty_config
ActiveGraph::Config[:verbose_query_logs] = false
end

# By default, Rails loads generators from load path.
# However, if we want to place generators at a different location we have to use "generators" hook
# https://api.rubyonrails.org/classes/Rails/Railtie.html
generators do
require File.expand_path('../rails/generators/migration_helper.rb', __dir__)
end

# Starting Neo after :load_config_initializers allows apps to
# register migrations in config/initializers
initializer 'neo4j.start', after: :load_config_initializers do |app|
Expand Down
3 changes: 3 additions & 0 deletions lib/rails/generators/migration_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@ def type_class
end
end
end

require 'rails/generators/named_base'
Rails::Generators::GeneratedAttribute.include ActiveGraph::Generators::GeneratedAttribute