Dwight Watson's blog

Absolute URL for an ActiveStorage attachment

This blog post was originally published a little while ago. Please consider that it may no longer be relevant or even accurate.

Not sure why, but I couldn't get url_for to give me an absolute URL with an ActiveStorage attachment, even when playing with all the options available. Turns out that polymorphic_url will give you what you're after though.

polymorphic_url(@post.header)

A blog about Laravel & Rails by Dwight Watson;

Picture of Dwight Watson

Follow me on Twitter, or GitHub.