Created
June 11, 2009 19:21
-
-
Save kmarsh/128168 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductImage < ActiveRecord::Base | |
belongs_to :product, :counter_cache => true | |
has_attached_file :image, | |
:styles => { :medium => "150x150>", :thumb => "100x100>" }, | |
:convert_options => { :all => "-quality 90 -strip" }, | |
:processors => Proc.new {|a| Rails.logger.info("Lambda at #{Time.now.to_f}"); a.processors }, | |
:url => "/product_images/:id/:style/:basename.:extension", | |
:path => ":rails_root/public/product_images/:id/:style/:basename.:extension" | |
named_scope :by_kind, lambda {|kind| { :conditions => { :kind => kind }, :limit => 1, :order => "created_at DESC" } } | |
attr_accessor :drop_shadow | |
def processors | |
Rails.logger.info("processors called on #{self.inspect} at #{Time.now.to_f}") | |
ret = drop_shadow? ? [:drop_shadow, :thumbnail] : [:thumbnail] | |
Rails.logger.info("returned #{ret.inspect}") | |
return ret | |
end | |
def drop_shadow? | |
boardize.to_i == 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment