app/models/spree/banner.rb in spree_banner-1.0.8 vs app/models/spree/banner.rb in spree_banner-1.1.0

- old
+ new

@@ -1,16 +1,16 @@ module Spree class Banner < ActiveRecord::Base attr_accessible :title, :url, :category, :position, :enabled, :attachment, :attachment_width, :attachment_height - + has_attached_file :attachment, :url => "/spree/banner/:id/:style_:basename.:extension", :path => ":rails_root/public/spree/banner/:id/:style_:basename.:extension", #:default_url => "/missing/:style.jpg", - :styles => { + :styles => lambda {|a| :thumbnail => "80x80#", - :custom => Proc.new { |instance| "#{instance.attachment_width}x#{instance.attachment_height}#" } + :custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#" }, :convert_options => { :thumbnail => "-gravity center" } @@ -23,24 +23,24 @@ scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} } # Load S3 settings if (FileTest.exist?(Rails.root.join('config', 's3.yml')) && !YAML.load_file(Rails.root.join('config', 's3.yml'))[Rails.env].blank?) S3_OPTIONS = { - :storage => 's3', - :s3_credentials => Rails.root.join('config', 's3.yml') - } + :storage => 's3', + :s3_credentials => Rails.root.join('config', 's3.yml') + } elsif (FileTest.exist?(Rails.root.join('config', 's3.yml')) && ENV['S3_KEY'] && ENV['S3_SECRET'] && ENV['S3_BUCKET']) S3_OPTIONS = { - :storage => 's3', - :s3_credentials => { - :access_key_id => ENV['S3_KEY'], - :secret_access_key => ENV['S3_SECRET'] - }, - :bucket => ENV['S3_BUCKET'] - } - else - S3_OPTIONS = { :storage => 'filesystem' } - end + :storage => 's3', + :s3_credentials => { + :access_key_id => ENV['S3_KEY'], + :secret_access_key => ENV['S3_SECRET'] + }, + :bucket => ENV['S3_BUCKET'] + } + else + S3_OPTIONS = { :storage => 'filesystem' } + end attachment_definitions[:attachment] = (attachment_definitions[:attachment] || {}).merge(S3_OPTIONS) def initialize(*args) super(*args)