diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 2a4acc1d0a..089c68139c 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -22,8 +22,23 @@ class Enterprise < ActiveRecord::Base accepts_nested_attributes_for :address accepts_nested_attributes_for :producer_properties, allow_destroy: true, reject_if: lambda { |pp| pp[:property_name].blank? } - has_attached_file :logo, :styles => { :medium => "300x300>", small: "180x180>", :thumb => "100x100>" } - has_attached_file :promo_image, :styles => { :large => "1200x260#", :thumb => "100x100>" } + has_attached_file :logo, + styles: { medium: "300x300>", small: "180x180>", thumb: "100x100>" }, + url: '/images/enterprises/logos/:id/:style/:basename.:extension', + path: 'public/images/enterprises/logos/:id/:style/:basename.:extension' + + has_attached_file :promo_image, + styles: { large: "1200x260#", thumb: "100x100>" }, + url: '/images/enterprises/promo_images/:id/:style/:basename.:extension', + path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension' + + validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/ + validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/ + + include Spree::Core::S3Support + supports_s3 :logo + supports_s3 :promo_image + validates_presence_of :name validates_presence_of :address diff --git a/app/models/enterprise_group.rb b/app/models/enterprise_group.rb index a06612a064..cdc9d9932a 100644 --- a/app/models/enterprise_group.rb +++ b/app/models/enterprise_group.rb @@ -7,14 +7,24 @@ class EnterpriseGroup < ActiveRecord::Base validates :description, presence: true attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids + attr_accessible :logo, :promo_image - attr_accessible :promo_image - has_attached_file :promo_image, styles: {large: "1200x260#"} + has_attached_file :logo, + styles: {medium: "100x100"}, + url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension', + path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension' + + has_attached_file :promo_image, + styles: {large: "1200x260#"}, + url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension', + path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension' + + validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/ validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/ - attr_accessible :logo - has_attached_file :logo, styles: {medium: "100x100"} - validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/ + include Spree::Core::S3Support + supports_s3 :logo + supports_s3 :promo_image scope :by_position, order('position ASC') scope :on_front_page, where(on_front_page: true) diff --git a/app/models/spree/taxon_decorator.rb b/app/models/spree/taxon_decorator.rb index 5f0ab4486f..10ee0b4719 100644 --- a/app/models/spree/taxon_decorator.rb +++ b/app/models/spree/taxon_decorator.rb @@ -1,5 +1,6 @@ Spree::Taxon.class_eval do - self.attachment_definitions[:icon][:path] = 'app/public/spree/taxons/:id/:style/:basename.:extension' + self.attachment_definitions[:icon][:path] = 'public/images/spree/taxons/:id/:style/:basename.:extension' + self.attachment_definitions[:icon][:url] = '/images/spree/taxons/:id/:style/:basename.:extension' # Indicate which filters should be used for this taxon