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

avoid asset_path route helper collisions #2511

Merged
merged 1 commit into from Apr 11, 2020

Conversation

granth
Copy link
Contributor

@granth granth commented Mar 25, 2020

If a Rails application has an assets route resource, than the generated asset_path route helper will override the asset helper of the same name.

Rails provides the aliases path_to_asset and url_to_asset to avoid this, and uses them internally. We can do the same here.

If a Rails application has an `assets` route resource, than the
generated `asset_path` route helper will override the asset helper
of the same name.

Rails provides the aliases `path_to_asset` and `url_to_asset` to
avoid this, and uses them internally. We can do the same here.
# Returns the relative path using manifest.json and passes it to asset_path helper.
# This will use asset_path internally, so most of their behaviors will be the same.
# Returns the relative path using manifest.json and passes it to path_to_asset helper.
# This will use path_to_asset internally, so most of their behaviors will be the same.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dithered on whether to rename the method in the comments, too, since path_to_asset is probably not as well known as asset_path. I thought it was better to be consistent.

@gauravtiwari gauravtiwari merged commit a84a4bb into rails:master Apr 11, 2020
@gauravtiwari
Copy link
Member

thanks @granth

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.

None yet

2 participants