# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
process convert: 'png', :resize_to_fit => [1024, 1024]
version :medium do
process resize_to_fit: [300, 300]
process convert: 'png'
end
version :thumb do
process resize_to_fit: [100, 100]
process convert: 'png'
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
- title "New Dog"
= render 'form'
%p= link_to "Back to List", dogs_path
class Picture < ActiveRecord::Base
belongs_to :attachable, polymorphic: true
attr_accessible :image, :attachable_id, :attachable_type
mount_uploader :image, ImageUploader
end
ActiveRecord::Schema.define(:version => 20110508171542) do
create_table "dogs", :force => true do |t|
t.string "name"
t.string "kennel_name"
t.integer "mother_id"
t.integer "father_id"
t.date "birthdate"
t.string "gender", :default => "F"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "pictures", :force => true do |t|
t.datetime "created_at"
t.datetime "updated_at"
t.string "image"
t.integer "attachable_id"
t.string "attachable_type"
end
end