Skip to content

Instantly share code, notes, and snippets.

@regedarek
Created January 26, 2012 23:42
Show Gist options
  • Save regedarek/1685881 to your computer and use it in GitHub Desktop.
Save regedarek/1685881 to your computer and use it in GitHub Desktop.
CarrierWave
# encoding: utf-8
class FileUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
storage :file
def store_dir
"photos/#{model.attachable_id}"
end
process :resize_to_limit => [500, 500]
process :convert => 'png'
version :medium do
process :resize_to_limit => [250, 250]
process :convert => 'png'
def full_filename (for_file = model.file)
"thumb_#{model.id}_medium.png"
end
end
version :small do
process :resize_to_limit => [50, 50]
process :convert => 'png'
def full_filename (for_file = model.file)
"thumb_#{model.id}_small.png"
end
end
def filename
"#{model.id}_original.png" if original_filename
end
end
#title
%h1
= @ad.title
#ad_content
%b Treść ogłoszenia:
= @ad.ad_content
%br
- if @ad.photos.present?
- @ad.photos.each do |p|
#photos
= image_tag("../../photos/#{@ad.id}/thumb_#{p.id}_small.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment