Skip to content

Commit

Permalink
Generators: respect model name if provided
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Alexander-Senko committed Nov 19, 2024
1 parent e9c8180 commit 68c2aff
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/generators/rails/presenter/presenter_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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

Expand Down

0 comments on commit 68c2aff

Please sign in to comment.