Reputation: 1397
I have searched for quite a bit on this issue and cannot seem to get it to work (stackoverflow, the Carrierwave Railscasts).
First off, I have zero issues uploading the image. That is working fine. Now the image is quite big and I would like to make it smaller. Currently my avatar_uploader.rb file is:
require 'carrierwave/orm/activerecord'
class AvatarUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
version :thumb do
process :resize_to_limit => [50,50]
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
After watching the railscasts (even though it's from the 2011), it seems you have to pass :thumb to your view, such as:
<%= image_tag(user.avatar(:thumb).to_s) %>
This is giving me an error in the browser of:
wrong number of arguments (1 for 0)
I'm not even sure it's necessary to have to pass :thumb into your view. Is it?
I know this is a fairly easy fix, so any help would be greatly appreciated!
Upvotes: 2
Views: 261
Reputation: 17647
It looks like the syntax has changed, since then. When in doubt, consult the official documentation:
uploader.url # => '/url/to/my_file.png' # size: 800x800
uploader.thumb.url # => '/url/to/thumb_my_file.png' # size: 200x200
or, in your case, probably:
user.avatar.thumb.url
Upvotes: 2