prevent /cable from being prepended to ActiveStorage route helpers #484
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.
Type of PR (feature, enhancement, bug fix, etc.)
Bug fix
Description
I observed that when using our brand new
render
helper to render a partial that contains ActiveStorage route helpers such asrails_blob_path
andobject.blob.representation
, the ActionCable mount URL would be prepended to the ActiveStorage route path generated, breaking the route.After substantial experimentation and general frustration, I was able to suppress this behaviour by setting the
SCRIPT_NAME
value to""
.I have verified that this solution provides a successful outcome in the following scenarios:
My current best guess is that if the change I made is going to cause problems, it'll be when trying to call our
render
helper inside of a Reflex, inside of an Engine.As of the time I'm creating this PR, I've not been able to test the above scenario. If someone is able to quickly spin up an engine to test, I would be highly appreciative.
Why should this be added
Developers rightly expect all Rails-provided helpers to work normally.
Checklist