不显示缩略图图像

时间:2017-06-07 09:53:36

标签: ruby-on-rails ruby

我正在使用载波和迷你宝石。这是我的索引视图中显示拇指图像的代码:

<div class="panel-body">
  Quantity  :<%= item.qty %><br>
  Price  : <%= number_to_currency(item.price, unit: "RS " ) %><br>
  <%= image_tag item.image_url(:thumb)%>
</div>

这是[{1}}:

中提供的代码
Image_uploader

没有class ImageUploader < CarrierWave::Uploader::Base # Include RMagick or MiniMagick support: # include CarrierWave::RMagick include CarrierWave::MiniMagick # Choose what kind of storage to use for this uploader: storage :file # storage :fog # Override the directory where uploaded files will be stored. # This is a sensible default for uploaders that are meant to be mounted: def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end version :thumb do process :resize_to_fit => [50, 50] end def extension_white_list %w(jpg jpeg gif png) end ;图像按原样显示。

:thumb

但它不能以拇指格式查看。它在localhost预览中显示图像名称和损坏的图像图标。

请帮我解决这个问题。

2 个答案:

答案 0 :(得分:1)

试试这个

x <- c("xid1=abc1000000\tyid2=pqr2000000\tzid3=olk78fgzu_zuii8999_ikooo",
   "xid4=oljhh88999\tyid5=lop9876666",
   "xid6=frdt876544\tyid7=ztr6u76532\tyid8=uzrt899963tzid8=wertttts_765342_ioooosww\tzid9=tzuuuee_66554422_88uuiiid")

OR

<%= image_tag item.thumbnail_url(:thumb) %>

去思考此链接,它会对你有所帮助。 reference

答案 1 :(得分:0)

使用以下代码块可以正常工作。

  <%= image_tag item.image_url(:thumb)%>