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
[ActiveStorage] url_for
returns path, not URL
#32948
Comments
url_for
returns path, not URLurl_for
returns path, not URL
This is a documented quirk of
To generate a fully-qualified URL, use |
Ah, thank you @georgeclaghorn ! I missed that in the documentation somehow. 👍 |
Would it be worthwhile to add a note about this to the Active Storage Overview guide page? I believe a note about this could be beneficial for those (like myself) using Rails as an API. When returning a JSON response with a URL to a file, a fully-qualified URL probably makes the most sense. It took me a while to hunt down this issue and realize I needed to use |
It seems rails 5.2.2 has the oposite default for |
Very confusing but indeed |
I agree that it would be good to document this in the overview active storage guide. |
thank you! |
Steps to reproduce
Call
url_for
on an active storage object (url_for(user.avatar)
)Expected behavior
The returned string will be a fully qualified URL. ( eg.
https://myserver.com/rails_storage/blob/foobar
)Actual behavior
Only the path is returned:
/rails_storage/blob/foobar
System configuration
Rails version: 5.2.0
Ruby version: 2.3.3p222
The text was updated successfully, but these errors were encountered: