So we've got our Rails 3.1(.1) site with assets in a few different places, and Rails (for some reason) expects those images hosted on Amazon S3 to be precompiled. The site-specific ones (stylesheets, little layout images, etc.) are local, they get successfully precompiled in production, and stored in public/assets, just like they should. They're served up via Apache just fine.
We have images that have URLs stored in the database that point at CDN-hosted images, and these URLs don't have a file extension; instead they have an MD5. They're http://path-to-cdn.com/<BIG-'OLE-MD5-HASH>. They're served through our views using Rails' image_tag helper just fine, they show up in production, they don't get sucked into our pre-compilation business (because they're dynamic, really, based on the product page on our site).
What's not fine are a third set of assets; they're stored on Amazon S3 with a similar hostname to where our site is served in production (the site is at, say, store.hostname.com and the assets are sitting at images.hostname.com.s3.amazonaws.com). When we visit a page with one of those images (and these images do have some sort of an extension; .jpg | .png | .gif, etc), we get a 500 error and a Sprockets error is filed about that image's URL not being precompiled.
I've seen some solutions where people feed a Proc to config.action_controller.asset_host, but I'm not sure that applies to my situation. I can't seem to find an answer to my solution.
Is there any way — besides writing the URL on the page to a raw HTML image tag (<img src=""/>) instead of a Rails image_tag? We'd really like to be able to use those nice helpers.
So from the comments it looks like the image urls in your database had whitespace as the first character which caused image_tag to look for an asset instead of linking straight to the url.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With