i don’t think im understanding this correctly, but how do i give users a default image?
def default_url
"/images/fallback/" + [version_name, "default.png"].compact.join('_')
end
i have an image called ‘default.png’ inside my images/fallback directory. ive seen online also people change the version_name to something like ‘tiny’ but that doesn’t seem to work for me either. what’s going on? what exactly is the version name?
i tried something like
def default_url
"/images/fallback/default.png"
end
but that doesn’t work either. what am i misunderstanding?
thanks!
edit:
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
???????
end
# Create different versions of your uploaded files:
version :thumb do
process :resize_to_fill => [80, 80]
end
end
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :name, :email, :password, :password_confirmation,
:remember_me, :image, :remote_image_url, :image_cache
mount_uploader :image, ImageUploader
end
For example you have uploader like this:
/images/fallback/default.pngstands for original image, forsmall_thumbversion path is/images/fallback/small_thumb_default.png, and so on.If you want the path where images actually saves after processing, you need
store_dir