Sha256: 20cae008b0b5c48d662d444ec456f23909038a1334a9cdcd610001e67a9acd8d

Contents?: true

Size: 670 Bytes

Versions: 21

Compression:

Stored size: 670 Bytes

Contents

module ImageCropper
  extend ActiveSupport::Concern

  included do

    # We use these accessors to pass values to CarrierWave and RMagick without
    # needing to store them in the database.
    # 
    attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

    # Like the accessors, this is used for cropping images.
    # 
    after_update :crop_image
  end

  # This simply makes carrierwave and rmagick recreate all its versions. We only
  # call it if the `crop_x` attribute is present, as we use that as our trigger.
  # Otherwise, we're recreating versions without changing anything.
  # 
  def crop_image
    filename.recreate_versions! if crop_x.present?
  end

end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
cambium-0.3.0 lib/generators/cambium/templates/app/models/concerns/image_cropper.rb