Sha256: 54f78da910eb664464265e1b3e4bd45d0b9a7b23dfa5fccf4755cc7d67fcc775
Contents?: true
Size: 911 Bytes
Versions: 4
Compression:
Stored size: 911 Bytes
Contents
# frozen_string_literal: true module Archangel ## # Asset model # class Asset < ApplicationRecord acts_as_paranoid mount_uploader :file, Archangel::AssetUploader before_save :save_asset_attributes validates :file, presence: true, file_size: { less_than_or_equal_to: Archangel.config.asset_maximum_file_size } validates :file_name, presence: true validate :valid_file_name belongs_to :site protected def save_asset_attributes return unless file.present? && file_changed? asset_object = file.file self.content_type = asset_object.content_type self.file_size = asset_object.size end def valid_file_name return if /^[\w-]+\.[A-Za-z]{3}$/ =~ file_name errors.add(:file_name, Archangel.t(:file_name_invalid)) end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
archangel-0.0.5 | app/models/archangel/asset.rb |
archangel-0.0.4 | app/models/archangel/asset.rb |
archangel-0.0.3 | app/models/archangel/asset.rb |
archangel-0.0.2 | app/models/archangel/asset.rb |