重新加载页面

时间:2017-12-02 22:39:11

标签: ruby-on-rails amazon-s3 carrierwave image-rotation

我使用了carrierwave对上传的图片进行了旋转操作。图片旋转并正确保存,但保存后,页面重新加载,我看不到旋转的图片。 (在开发中这是有效的,但不在生产中 - Heroku)从S3桶我可以看到图像立即正确旋转。只有在浏览器中之后:

Open image in new tab > manually reload page > then I see correctly rotated picture.

我该如何解决这个问题?感谢。

课程广告:

attr_accessor :rotate_picture_side
attr_accessor :picture_index

after_save {rotate_selected_picture if should_rotate_picture?}

private
def rotate_selected_picture
  self.pictures[picture_index].recreate_versions!
end

def should_rotate_picture?
  self.rotate_picture_side.present? && self.picture_index.present?
end

类PicturesController:

  def update
    @ad.rotate_picture_side = params[:rotate_picture_side]
    @ad.picture_index = params[:id].to_i
    @ad.save
    redirect_to edit_ad_path(@ad, anchor: "rotate-picture #
     {@ad.picture_index}")
  end

class PicturesUploader:

   def rotate_picture
     manipulate! do |pic|
       if model.rotate_picture_side == "right"
         pic.rotate "90"
       elsif model.rotate_picture_side == "left"
        pic.rotate "270"
       end
       pic #returns the manipulated picture
     end
   end

0 个答案:

没有答案