CarrierWave / non-form cloud cached images redisplayed in dev environment

When the form has an error, the cached image is not displayed. He tries to go to the Cloudmin server and upload an image that does not exist.

Here is what the source ends up with:

       <div class="form-group">
          <label class="col-sm-3 control-label" for="guide_image">Image</label>
          <div class="col-sm-9">
            <img alt="Ho97jzyhfjludw129u8m" src="http://res.cloudinary.com/memorycommit/image/upload/ho97jzyhfjludw129u8m.jpg" />
            <input class="form-control" id="guide_image" name="guide[image]" type="file" />
            <input id="guide_image_cache" name="guide[image_cache]" type="hidden" value="1402249607-3970-6368/mountain-top-med.jpg" />
          </div>
        </div>

Here is my code for the image:

       <div class="form-group">
          <%= f.label :image, class: "col-sm-3 control-label" %>
          <div class="col-sm-9">
            <%= image_tag(@guide.image_url) if @guide.image? %>
            <%= f.file_field :image, class: "form-control" %>
            <%= f.hidden_field(:image_cache) %>
          </div>
        </div>

image_uploader.rb

class ImageUploader < CarrierWave::Uploader::Base

  include Cloudinary::CarrierWave

  version :standard do
    process :resize_to_fill => [220, 220, :north]
  end

  version :thumbnail do
    resize_to_fit(120, 120)
  end
end

What am I doing wrong?

+4
source share
1 answer

Unfortunately, the method cl_image_tagdoes not support returning a local URL (for example, an image from image_cache).

0
source

Source: https://habr.com/ru/post/1543774/


All Articles