Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError 'crop' in uploader #19

Open
ghost opened this issue Dec 3, 2015 · 1 comment
Open

NoMethodError 'crop' in uploader #19

ghost opened this issue Dec 3, 2015 · 1 comment

Comments

@ghost
Copy link

ghost commented Dec 3, 2015

Hi,
I have an error on rails 4.2 using the gem carrierwave-crop 0.1.2.
when I try to crop the image an error occurs:

NoMethodError (undefined method `crop' for #LocationShowcaseUploader::Uploader70164076328740:0x007fa0b6842a98)

my code:

class LocationShowcase < ActiveRecord::Base
  # other stuff..

  mount_uploader :image, LocationShowcaseUploader, mount_on: :image_file_name
  crop_uploaded :image

  # other stuff..
end
class LocationShowcaseUploader < CarrierWave::Uploader::Base
  include CarrierWave::Compatibility::Paperclip
  include SharedUploader
  include CarrierWave::MiniMagick
  include CarrierWave::ImageOptimizer

  # other stuff..

  version :default do
    process resize_to_fit: [600, -1], optimize: [{ quality: 60 }]
  end

  version :large, if: :is_cropped? do
    process crop: :default
    process resize_to_fit: [1335, -1], optimize: [{ quality: 60 }]
  end

  version :medium, if: :is_cropped? do
    process crop: :default
    process resize_to_fit: [770, -1], optimize: [{ quality: 60 }]
  end

  version :small, if: :is_cropped? do
    process crop: :default
    process resize_to_fit: [610, -1], optimize: [{ quality: 60 }]
  end

  version :admin, if: :is_cropped? do
    process crop: :default
    process resize_to_fit: [-1, 70], optimize: [{ quality: 60 }]
  end

  private

  def is_cropped?(image)
    model.image_crop_x.present?
  end

end
@petertoth
Copy link

Maybe too late to the party but I had the same problem. Noticed had gem "carrierwave-crop" before gem "carrierwave" inside my Gemfile. Changed the order, did bundle install and the error disappeared.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant