Sha256: e4a9ddb2c463c6504cf47e4d076bf453cd82a3568e01bcc3338eccbfe02843d5

Contents?: true

Size: 827 Bytes

Versions: 5

Compression:

Stored size: 827 Bytes

Contents

class Photo < ActiveRecord::Base
  belongs_to :product

  scope :photos, :conditions => "hidden != true"

  NO_IMAGE_PATH  = "/assets/not_available/medium/not_found.png"
  
  has_attached_file :photo,
                    :styles      => { :thumb => "95x95#", :large => "450x300" },
                    :default_url => "/assets/not_available/:style/not_found.png",
                    :url         => "/assets/photos/:id/:style/:basename.:extension",
                    :path        => ":rails_root/public/assets/photos/:id/:style/:basename.:extension"

  validates_attachment_size :photo, :less_than => 1000.kilobytes

  validate :photo, :presence => true, :content_type => ['image/jpeg', 'image/jpg', 'image/gif', 'image/png']

  def alt
    self.photo_file_name.dasherize.titleize.gsub(/\.(jpeg|jpg|gif|png)$/i,'')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ecommerce-0.0.6 app/models/photo.rb
ecommerce-0.0.5 app/models/photo.rb
ecommerce-0.0.4 app/models/photo.rb
ecommerce-0.0.3 app/models/photo.rb
ecommerce-0.0.2 app/models/photo.rb