Dzięki!
To rzeczywiście kwestia config.cache_classes = false.
Tylko teraz pewnie ucierpi wydajność.
Oto cały kod generujący miniaturki (wersje):[code=ruby]class Version < ActiveRecord::Base
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
hobo_model # Don’t put anything above this
fields do
podpis :string
caption :string
timestamps
end
belongs_to :foto
belongs_to :resolution, :class_name => “VersionDefinition”
before_update :reprocess_photo, :if => :cropping?
before_create :clone_photo, :if => :crop_auto?
has_attached_file :photo_crop,
:styles => { :thumb => “100x100”,
:crop => Proc.new { |instance| instance.crop_format },
:original => { :geometry => Proc.new { |instance| instance.foto_format },
:processors => [:cropper] },
},
:convert_options => { :crop => Proc.new { |instance| instance.crop_options } }
— Paperclip —
def ratio
resolution.width.to_f / resolution.height.to_f
end
def clone_photo
self.photo_crop = foto.photo
end
def foto_format
“#{foto.photo.styles[:big][:geometry]}”
end
def crop_format
if cropping?
“#{crop_resolution}”
else
“#{crop_resolution}>”
end
end
def crop_options
“-background white -gravity center -extent #{crop_resolution}” if resolution.crop == :auto
end
def crop_resolution
“#{resolution.width}x#{resolution.height}”
end
def cropping?
crop_x.present? && crop_y.present? && crop_w.present? && crop_h.present?
end
def crop_auto?
resolution.crop == :auto
end
def reprocess_photo
clone_photo unless photo_crop.file?
end
end[/code]
Oraz procesor:[code=ruby]module Paperclip
class Cropper < Thumbnail
def transformation_command
if crop_command
crop_command + super.sub(/ -crop \S+/, ‘’)
else
super
end
end
def crop_command
target = @attachment.instance
if target.cropping?
" -crop '#{target.crop_w}x#{target.crop_h}+#{target.crop_x}+#{target.crop_y}'"
end
end
end
end[/code]