Get absolute URL for paperclip attachment

前端 未结 7 2064
长发绾君心
长发绾君心 2021-02-02 10:19

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: RackBa

相关标签:
7条回答
  • 2021-02-02 10:44

    try

    URI.join(request.url, @model.attachment_name.url)
    

    or

    URI(request.url) + @model.attachment_name.url
    

    It's safe if you use S3 or absolute url.

    Update: this answer is better than mine ;) https://stackoverflow.com/a/21027839/683157

    0 讨论(0)
提交回复
热议问题