Sha256: 3fa97af31f68ee617690108e88a0036139c8a74293e26b05483c071554fa1820
Contents?: true
Size: 1.17 KB
Versions: 13
Compression:
Stored size: 1.17 KB
Contents
module Guts # Medium model which utilizes PaperClip class Medium < ActiveRecord::Base include TrackableConcern include MultisiteScopeConcern # Regex used for sizing_only_images CONTENT_TYPE_REGEX = %r{^(image|(x-)?application)/(x-png|pjpeg|jpeg|jpg|png|gif)$} validates :title, presence: true, length: { minimum: 3 } belongs_to :filable, polymorphic: true, required: false has_many :tracks, as: :object has_attached_file( :file, source_file_options: { all: '-auto-orient' }, styles: Guts.configuration.file_image_sizing, url: '/system/:class/:id_partition/:style/:filename', path: ':rails_root/public/system/:class/:id_partition/:style/:filename' ) before_post_process :sizing_only_images validates_attachment_content_type( :file, content_type: Guts.configuration.file_allowed_content_types ) trackable :create, :destroy # Determine if the file is an image # and can be resized by Paperclip # @return [Boolean] true for image, false for file def sizing_only_images false unless self[:file_content_type] =~ CONTENT_TYPE_REGEX end end end
Version data entries
13 entries across 13 versions & 1 rubygems