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

How-to: Using carrierwave-crop w Mongoid #15

Open
fshafiee opened this issue Jul 7, 2015 · 0 comments
Open

How-to: Using carrierwave-crop w Mongoid #15

fshafiee opened this issue Jul 7, 2015 · 0 comments

Comments

@fshafiee
Copy link

fshafiee commented Jul 7, 2015

Hi everyone,
I just wanted point out that this gem can be used with Mongoid. All you have to do is to add necessary modules in the model; Just the two lines of code noted in following example.

class Profile

  include Mongoid::Document
  include Mongoid::Timestamps

  # Include these modules to use carreirwave-crop
  extend CarrierWave::Crop::ModelAdditions::ClassMethods
  include CarrierWave::Crop::ModelAdditions::InstanceMethods

  # ... rest of the model ...

  # you can use carrierwave-crop methods same way as before
  mount_uploader :avatar, AvatarUploader
  crop_uploaded :avatar

end

Cheers, Farzad.

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