gpt4 book ai didi

ruby-on-rails - 升级到 Rails 3.2 后回形针更改图像路径

转载 作者:数据小太阳 更新时间:2023-10-29 06:39:14 25 4
gpt4 key购买 nike

升级到 Rails 3.2(从 3.0.10 开始)后,回形针 (3.0.2) 出现问题。

原来一张图片的路径是:

"http://localhost:3000/system/photos/94/small/AudiLogo.jpg?1335392139"

升级后这种图片再也不会显示了!但是如果我上传一张新图片这将在页面上正常显示,但是使用的新路径是:

"localhost:3000/system/products/photos/000/000/094/smal/AudiLogo.jpg?1335392139"

升级中发生了什么?有没有将旧路径转换为新路径的解决方案?

我尝试使用“rake paperclip:refresh:missing_styles”,但没有用。

回形针配置部分就是这个。

has_attached_file :photo,
:processors => lambda { |a|
if a.external?
[:thumbnail]
else
[:thumbnail,:watermark]
end
},
:styles => {
:slider => { :geometry => "350x312#", :format => :jpg, :watermark_path => "#{Rails.root}/public/images/watermark.png", :position => "NorthEast" },
:small => "100x50>",
:medium => "200>x200",
:thumb => "100x100>",
:big => { :geometry => "640x480>", :format => :jpg, :watermark_path => "#{Rails.root}/public/images/watermark.png" }
},
:default_url => "/images/noimage.png"

提前致谢。

最佳答案

我遇到了同样的问题。您可以通过创建一个类似config/initializers/paperclip.rb 的文件来解决这个问题,然后将

Paperclip::Attachment.default_options.merge!(
:path => ":rails_root/public/system/:attachment/:id/:style/:basename.:extension",
:url => "/system/:attachment/:id/:style/:basename.:extension"
)

关于ruby-on-rails - 升级到 Rails 3.2 后回形针更改图像路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10325288/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com