Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Carrierwave image not resizing

I know the lessons use the paperclip gem but I was having issues with it and decided to switch to carrierwave. I've set it up fine but there's one issue. I can't get the images to resize. If anyone has any experience with carrierwave help would be very appreciated. I am using rails 4.


version :thumb do process :scale => [50, 50] end

link I am using in my index.html.erb and show.html.erb:

<%= image_tag log.attachment.url(:thumb).to_s%>

here is my log_uploader.rb file:

class LogUploader < CarrierWave::Uploader::Base

include CarrierWave::MiniMagick

storage :file

def store_dir "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}" end

process :scale => [50, 50

def scale(width, height) end

version :thumb do process :scale => [50, 50]



3 Answers

I would read MiniMagick's manual on the resizing/geometry-resizing parameters it uses for its interface regarding resizing images, it's not necessarily a problem of Carrierwave.

It shouldn't be too different from ImageMagick from what I recall from dabbling with MiniMagick/RMagick back in the day.

Nonetheless, if you're going to be going through the Advanced Rails tutorials on Treehouse, you'll be seeing Paperclip a lot, and Paperclip's rather pretty intuitive to use thanks to the very detailed documentation Thoughtbot provides.

What exactly were the issues you had with it? Perhaps they can be easily be resolved and not a big deal than you thought they were.

thanks I'll check out minimagicks manual, and the image was alway appearing broken when I was trying to upload a profile picture, and I'm pretty sure I had it set up correctly (i thinkl lol)

The latter part is regarding Paperclip? If so, make sure you used rake paperclip:refresh CLASS=<Whatever Model Having The Problem> to allow Paperclip to make variants of the original it couldn't have made for you already with style variants you've defined since it was initialized.

For example, if I decide to create a retina-ready, thumbnail variant of an image attribute for a model of mine like the code snippet below, it won't automatically add that style to existing instances of that model and I'll have to use the rake task to make an app-wide change (like you're supposed to), regardless if I immediately begin to use the style in my views.

 has_attached_file :avatar, default_url: '/images/missing.png', styles: {
    thumbnail: "279x279#",
    thumbnail_retina_ready: "558x558#"

Does that make sense, alicia glenn?