From 68c2aff6c45ba4422487bd96afb2ecb6d077f31b Mon Sep 17 00:00:00 2001 From: Alexander Senko Date: Mon, 18 Nov 2024 22:28:25 +0700 Subject: [PATCH] Generators: respect model name if provided Presenters should respect `--model-name` passed to `scaffold_controller` generator or any other one supporting this option. That could be of a particular use to solve namespace issues (e.g., when controllers are namespaced and models are not). See also drapergem/draper#919. --- lib/generators/rails/presenter/presenter_generator.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/generators/rails/presenter/presenter_generator.rb b/lib/generators/rails/presenter/presenter_generator.rb index 180aee8..b6b326a 100644 --- a/lib/generators/rails/presenter/presenter_generator.rb +++ b/lib/generators/rails/presenter/presenter_generator.rb @@ -3,6 +3,7 @@ module Rails class PresenterGenerator < Generators::NamedBase # :nodoc: include Magic::Presenter::Generator + include Generators::ResourceHelpers source_root File.expand_path('templates', __dir__) @@ -19,7 +20,9 @@ def create_presenter_file template 'presenter.rb', "#{file_path}.rb" end - hook_for :test_framework + hook_for :test_framework do |generator| + invoke generator, [ name ] + end private