gpt4 book ai didi

ruby-on-rails - 回形针不生成缩略图,静默失败

转载 作者:行者123 更新时间:2023-12-04 16:48:39 26 4
gpt4 key购买 nike

我在这里拉扯我的头发......我不知道为什么这不起作用。

我正在使用 ruby​​ 1.8.7、rails 3.0.19、回形针 2.7.4。

我的模型:

has_attached_file :photo,  :styles => {
:logo => "60x20",
:widget => "60x40",
:thumb=> "100x100",
:small => "150x150>" },
:url => "/images/companies/:id/:style/:basename.:extension",
:path => ":rails_root/public/images/companies/:id/:style/:basename.:extension",
:default_url => "/images/bb_noimage.png"

#validates_attachment_presence :photo
validates_attachment_size :photo, :less_than => 3.megabytes
validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/png','image/gif','image/jpg']

在 View 中:

<%= image_tag "#{get_image_url(company.id,company.photo_file_name,"small")}"%>

问题是一些文件夹将具有“大”和“拇指”大小,但不会具有“小”和“ Logo ”大小 - 我在很长一段时间没有使用它后重新访问该站点。我想要生成缺少的样式。我尝试了这些命令,第一个没有显示错误,但第二个显示了以下错误。 Niether 生成所需的缩略图。感谢您的帮助!

bundle exec rake paperclip:refresh:thumbnails CLASS=Company
bundle exec rake paperclip:refresh:missing_styles --trace

** Execute paperclip:refresh:thumbnails
rake aborted!
No such file or directory - /Users/q/Sites/baiabase-old/public/system/paperclip_attachments.yml
/Users/q/.rvm/gems/ruby-1.8.7-p302@baia-old/gems/paperclip-2.7.4/lib/paperclip/missing_attachment_styles.rb:25:in `initialize'

最佳答案

添加到您的模型

    attr_accessible :photo, :photo_file_name

has_attached_file :photo, :styles => {.....
....your code...

在 View 中

<%= image_tag @company.photo.url(:small) %>

关于ruby-on-rails - 回形针不生成缩略图,静默失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14450246/

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