Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent /cable from being prepended to ActiveStorage route helpers #484

Merged
merged 1 commit into from
Apr 6, 2021

Conversation

leastbad
Copy link
Contributor

@leastbad leastbad commented Apr 6, 2021

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 as rails_blob_path and object.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:

  • rendering partials within partials
  • calling current_user.name
  • calling a controller-specific helper
  • calling a route helper

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

  • My code follows the style guidelines of this project
  • Checks (StandardRB & Prettier-Standard) are passing
  • This is not a documentation update

@leastbad leastbad merged commit 5375a85 into stimulusreflex:master Apr 6, 2021
@leastbad leastbad deleted the script_name branch August 16, 2021 03:16
marcoroth pushed a commit to marcoroth/stimulus_reflex that referenced this pull request Oct 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant