Get absolute URL for paperclip attachment

sleepy_keita picture sleepy_keita · Sep 23, 2012 · Viewed 29.3k times · Source

Is it possible to get the absolute URI for a Paperclip attachment? Right now, the problem is that the production environment is deployed in a sub-URI (on Passenger: RackBaseURI), but <paperclip attachment>.url returns the Rails-app relative URI (/system/images/...). Is there a way to get the absolute URI for Paperclip attachments?

I'm using Paperclip v2.7 and Rails 3.2.8.

Answer

Chris Bosco picture Chris Bosco · Aug 8, 2014
asset_url(model.attachment_name.url(:style))

Relevant github issue