Full url for an image-path in Rails 3

前端 未结 9 1523
说谎
说谎 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:46

    You can't refer to request object in an email, so how about:

    def image_url(*args)
        raw(image_tag(*args).sub /src="(.*?)"/, "src=\"//#{ActionMailer::Base.default_url_options[:protocol]}#{ActionMailer::Base.default_url_options[:host]}" + '\1"')
    end
    

提交回复
热议问题