Bla*_*son 4 ruby-on-rails rmagick ruby-on-rails-3 dragonfly-gem
我正在使用Dragonfly并希望有一个默认图像,其缩放方式与缩略图相同.
我目前有以下代码,但是当Dragonfly使用fetch_file方法时,它会尝试处理缩略图,但生成的URL是一个死链接.
if listing.image
image = listing.image.jpg
else
image = Dragonfly[:images].fetch_file('/toekomst/images/speech-bubble.png')
end
image_tag image.jpg.thumb(size).url, :class => "framed"
Run Code Online (Sandbox Code Playgroud)
我在这方面找不到多少帮助,所以任何提示都非常感谢!谢谢!
你需要将配置值'allow_fetch_file'设置为true - 默认情况下,使用fetch_file对服务器进行请求是为安全性而关闭的(除此之外没有特别说明:http: //markevans.github.com/dragonfly/Dragonfly /Server.html 但是,如果你这样做,你可能应该将'protect_from_dos_attacks'打开为true,再次为了安全起见:
Dragonfly[:images].configure do |c|
# ...
c.allow_fetch_file = true
c.protect_from_dos_attacks = true
c.secret = "some secret here..."
end
Run Code Online (Sandbox Code Playgroud)
希望有所帮助
| 归档时间: |
|
| 查看次数: |
2533 次 |
| 最近记录: |