title: Rotate image with Paperclip 5
body: <p>I've got photo on my model</p>
  
  <pre><code>has_attached_file :photo, BucketConfig.default.merge(
        processors: [:rotator],
        styles: {
            original: Proc.new { |a| { rotation: a.rotation } }
        },
        default_url:  ActionController::Base.helpers.asset_path('assets/request_default.png')
    )
  </code></pre>
  
  <p>To catch a rotation param I do something like this</p>
  
  <pre><code>attr_accessor :rotation
  
      before_save :adjust_rotation
      before_update :reprocess_image
  
      protected
  
      def adjust_rotation
        self.rotation = self.rotation.to_i
        self.rotation = self.rotation % 360 if self.rotation &gt;= 360 || self.rotation &lt;= -360
      end
  
      def reprocess_image
        self.photo.reprocess! unless self.rotation.zero?
      end
  </code></pre>
  
  <p>my Rotator process in lib/paperclip</p>
  
  <pre><code>module Paperclip
    class Rotator &lt; Processor
      def transformation_command
        if rotator_command
          rotator_command + super.join(' ')
        else
          super
        end
      end
  
      def rotator_command
        target = @attachment
        if target.rotation.present?
          " -rotate #{target.rotation} "
        end
      end
    end
  end
  </code></pre>
  
  <p>When I call</p>
  
  <pre><code>m = Model.first
  m.rotation=90
  m.save
  </code></pre>
  
  <p>I've got error:</p>
  
  <pre><code>NoMethodError - undefined method `closed?' for nil:NilClass
  Did you mean?  clone:
    paperclip (4.3.7) lib/paperclip/attachment.rb:582:in `block in unlink_files'
    paperclip (4.3.7) lib/paperclip/attachment.rb:581:in `unlink_files'
    paperclip (4.3.7) lib/paperclip/attachment.rb:536:in `post_process_style'
    paperclip (4.3.7) lib/paperclip/attachment.rb:511:in `post_process_styles'
    paperclip (4.3.7) lib/paperclip/attachment.rb:504:in `block (2 levels) in post_process'
  </code></pre>
  
  <p>Why my reprocess! method doesn't work ? Do I something wrong with my rotator process? Where's the problem?</p>