Skip to content

Commit

Permalink
generator to create initializer
Browse files Browse the repository at this point in the history
in order to load all the domains under the application's namespace, we
have to fudge around with the Rails autoloader a little bit. this piece
of initializer code ensures that all domains are loaded under the
application's namespace, and ready when you need them.
  • Loading branch information
yawboakye committed Jun 6, 2024
1 parent 5c704d8 commit 0c14172
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/generators/categoria/initializer_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# typed: strict
# frozen_string_literal: true

module Categoria
module Generators
class InitializerGenerator < ::Rails::Generators::Base
sig { void }
def create_categoria_initializer_file
in_root do
create_file "config/initializers/categoria.rb", <<~INITIALIZER
# frozen_string_literal: true
Rails.autoloaders.main.push_dir(
"\#{Rails.root}/app/lib",
namespace: Rails.application.class.module_parent
)
INITIALIZER
end
end
end
end
end

0 comments on commit 0c14172

Please sign in to comment.