feat: add support for custom helper names via js_helper_name parameter #62
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description 📖
This pull request adds support for customizing generated helper names in routes using a new
js_helper_nameparameter. This allows developers to override the automatic helper name generation and maintain consistent naming patterns across polymorphic controllers and complex route structures.Background 📜
This was happening because the automatic helper name generation creates inconsistent names for polymorphic controllers. For example, with an
admin_update_logscontroller that handles both receipts and referrals, the generated helpers were:The first route gets a generic
indexname while the second gets a verbose auto-generated name, creating inconsistency in the JavaScript API and making it harder to maintain a predictable naming pattern across related routes.The Fix 🔨
By changing the generator to check for a
js_helper_nameparameter in route defaults before falling back to automatic name generation:And allowing developers to specify custom names in their routes:
This now generates consistent, descriptive helper names:
The fix maintains backward compatibility while giving developers full control over helper naming for complex route structures and polymorphic controllers.