Ruby on rails 3.2 Carrierwave转换,但image_标记调用为旧名称
上传者进行正确的处理Ruby on rails 3.2 Carrierwave转换,但image_标记调用为旧名称,ruby-on-rails-3.2,carrierwave,Ruby On Rails 3.2,Carrierwave,上传者进行正确的处理 version :thumb do process :resize_to_limit => [200, 200] process :convert => 'jpg' def filename super.chomp(File.extname(super)) + '.jpg' end end 在存储目录中,上载的文件及其缩略图都在那里。并将缩略图转换为jpg 然而,该剧的观点是 <%= image_ta
version :thumb do
process :resize_to_limit => [200, 200]
process :convert => 'jpg'
def filename
super.chomp(File.extname(super)) + '.jpg'
end
end
在存储目录中,上载的文件及其缩略图都在那里。并将缩略图转换为jpg
然而,该剧的观点是
<%= image_tag @docimage.production_file_url(:thumb).to_s %>
正在呈现指向原始名称的路径
<img alt="Thumb_30x30_2mb" src="/uploads/docimage/yadayadayada/thumb_30x30_2mb.tif" />
我在处理新扩展时缺少了一些东西。我想我希望有一个现有的方法来处理这个案例。但考虑到解决方案的简洁性,这是大错特错的
def edited_thumb
start_path = self.production_file_url(:thumb)
edited_thumb = start_path.sub(/[^.]+\z/,"jpg")
end
那么,在视图中,
<%= image_tag @model.edited_thumb %>