ruby on rails 3.2 - Carrierwave converts but image_tag call is to old name -
ruby on rails 3.2 - Carrierwave converts but image_tag call is to old name -
an uploader proper handling
version :thumb process :resize_to_limit => [200, 200] process :convert => 'jpg' def filename super.chomp(file.extname(super)) + '.jpg' end end
in store directory uploaded file , thumbnail there. , thumbnail converted jpg.
however show view
<%= image_tag @docimage.production_file_url(:thumb).to_s %>
is rendering path original name
<img alt="thumb_30x30_2mb" src="/uploads/docimage/yadayadayada/thumb_30x30_2mb.tif" />
i'm missing here handling new extension.
i guess expecting existing method handle case. given brevity of solution, wildly mistaken.
def edited_thumb start_path = self.production_file_url(:thumb) edited_thumb = start_path.sub(/[^.]+\z/,"jpg") end
then, in view
<%= image_tag @model.edited_thumb %>
ruby-on-rails-3.2 carrierwave
Comments
Post a Comment