bendytree
bendytree

Reputation: 13609

Rails - Url to a Static Assets in /Public

I'm using S3 to serve my public folder & trying to build a simple URL to one of these assets.

My production.rb has:

config.action_controller.asset_host = "https://my-bucket.s3.amazonaws.com"

And this works perfect in my .erb files:

<%= image_tag("rails.png") %>
# => <img src="https://my-bucket.s3.amazonaws.com/rails.png" />

But I need a url (not a tag) for a GENERIC file type, like:

<%= asset_host "foo.bar" %>
# => https://my-bucket.s3.amazonaws.com/foo.bar

What is the magic, two-word, underscore joined, rails phrase that gives me this url?

Upvotes: 3

Views: 2061

Answers (1)

James
James

Reputation: 4807

Use <%= asset_path "foo.bar" %>.

Upvotes: 2

Related Questions