Full url for an image-path in Rails 3

前端 未结 9 1477
说谎
说谎 2020-12-13 09:14

I have an Image, which contains carrierwave uploads:

Image.find(:first).image.url #=> \"/uploads/image/4d90/display_foo.jpg\"

In my vie

9条回答
  •  春和景丽
    2020-12-13 09:39

    try path method

    Image.find(:first).image.path
    

    UPD

    request.host + Image.find(:first).image.url
    

    and you can wrap it as a helper to DRY it forever

    request.protocol + request.host_with_port + Image.find(:first).image.url
    

提交回复
热议问题