diff --git a/lib/generators/stimulus/stimulus_generator.rb b/lib/generators/stimulus/stimulus_generator.rb index 5af2437..80e1e2f 100644 --- a/lib/generators/stimulus/stimulus_generator.rb +++ b/lib/generators/stimulus/stimulus_generator.rb @@ -17,6 +17,6 @@ def controller_name end def stimulus_attribute_value(controller_name) - controller_name.gsub(/\//, "--").gsub("_", "-") + controller_name.gsub(/\//, "--").tr("_", "-") end end diff --git a/lib/stimulus/manifest.rb b/lib/stimulus/manifest.rb index 709e594..c22137b 100644 --- a/lib/stimulus/manifest.rb +++ b/lib/stimulus/manifest.rb @@ -13,7 +13,7 @@ def import_and_register_controller(controllers_path, controller_path) controller_path = controller_path.relative_path_from(controllers_path).to_s module_path = controller_path.split('.').first controller_class_name = module_path.underscore.camelize.gsub(/::/, "__") - tag_name = module_path.remove(/_controller/).gsub(/_/, "-").gsub(/\//, "--") + tag_name = module_path.remove(/_controller/).tr("_", "-").gsub(/\//, "--") <<-JS