Sha256: 3cd5926dc953acb1922d456c356a9223706769c8969e61598e06fc516ced11d6
Contents?: true
Size: 780 Bytes
Versions: 39
Compression:
Stored size: 780 Bytes
Contents
class Asset < ApplicationRecord include Concerns::Taggable mount_uploader :filename, AssetUploader has_many :images, dependent: :destroy has_many :content_pictures, dependent: :destroy scope :image, -> { where(content_type: %w(image/gif image/jpeg image/png)) } before_save :update_filesize, :update_content_type validates :filename, presence: true def image? content_type.to_s.include?('image') end def image Udongo::Assets::Resizer.new(self) if image? end def actual_filename read_attribute(:filename) end def deletable? images.empty? && content_pictures.empty? end private def update_filesize self.filesize = filename.size end def update_content_type self.content_type = filename.content_type end end
Version data entries
39 entries across 39 versions & 1 rubygems