1

I'm using rmagick to rotate my picture. So, basically when testing, after I invoked the rotate function and it executed successfully. I need to refresh the browser to see the result. That's normal.

So here come the question: when I move to controller method, after I invoked the function and make a redirect_to, it don't display the correct rotated picture. In case, I have to refresh my browser again to see the result. What possible that caused this issues?

my controller function is something like this:

def update
  @pic = Photo.find(params[:id]
  @pic.rotate_direction(90)
  redirect_to edit_photo_path(@pic)
end

My rotation function is working well. I suspect that caching is the problem, but when I use browser that don't save cache,it still remain the same result. Anyone faces this issues?

Nich
  • 1,112
  • 1
  • 14
  • 29
  • you dont need the refresh.. http://stackoverflow.com/questions/11832131/cross-browser-way-to-rotate-image-using-css – AJcodez Jun 07 '13 at 18:04
  • hmm, i need user to trigger whether they want to rotate and save the picture. Therefore, the case for CSS is not useful to me – Nich Jun 07 '13 at 18:12
  • you can use jquery to add or remove a `.rotated` class. not sure why you need to refresh again, so just suggesting alternatives :) – AJcodez Jun 07 '13 at 18:15
  • btw thanks, because I got different version of picture in different place,I need to retrieve those from s3 and rotate them as well and restore back to the s3. – Nich Jun 07 '13 at 18:59
  • and actually is not my wishes to refresh again since redirect_to actually did a refresh page effect. But I have to refresh it again after my redirect_to to show my proper result. So, I'm curious what's going on. – Nich Jun 07 '13 at 19:02

1 Answers1

2
require 'RMagick'

def rotate
    photo   = Photo.find(params[:id])
    image   = Magick::ImageList.new(photo.file)
    image   = image.rotate(90)
    image.write(photo.file)

end
Marcelo Austria
  • 861
  • 8
  • 16