14

i have a problem with paperclip (3.0.2) after upgrade to rails 3.2 (from 3.0.10).

Originally the path of one image was:

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

and after the upgrade this kind of images never show again!, but if i upload a new picture this will display fine on page, but the new path that use is:

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

Whats happend in the upgrade ? There's any solution for convert the olds path to new ?

I try with "rake paperclip:refresh:missing_styles" but dosen't works.

The paperclip config section it's this.

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"

Thanks in advance.

4

3 回答 3

15

我有同样的问题。您可以通过创建一个像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"
)
于 2012-06-06T19:54:17.233 回答
3

我刚刚进行了类似的升级并以这种方式解决了我的问题:

  has_attached_file :image,
    :url => "/images/photos/:id/:basename_:style.:extension",
    :path => ":rails_root/public/images/photos/:id/:basename_:style.:extension",
于 2012-04-26T16:08:52.617 回答
1

假设原始路径和当前路径之间的“小”与“小”差异是拼写错误,另一个明显的变化是在“/photos/”之后添加了两个数字段。

".../photos/000/000/094/smal/AudiLogo.jpg?1335392139"

我怀疑这是来自用于路径的 id_partition。您是否在其他地方设置了不同的默认路径插值?

查看 Paperclip 的代码,我看到了负责此问题的id_partition 方法,但仍未找到任何指向默认行为更改方向的文档。我没有遵循 gem 中的代码来确定它是错误还是未记录的更改。

于 2012-04-26T15:59:16.617 回答