Sha256: df5e218f1f0ec0c431f29f8021c4da01efa58fd85b58ba68e465329d53cf2465

Contents?: true

Size: 836 Bytes

Versions: 6

Compression:

Stored size: 836 Bytes

Contents

class Cms::File < ActiveRecord::Base
  
  set_table_name :cms_files
  
  cms_is_categorized
  
  # -- AR Extensions --------------------------------------------------------
  has_attached_file :file, ComfortableMexicanSofa.config.upload_file_options
  
  # -- Relationships --------------------------------------------------------
  belongs_to :site
  
  # -- Validations ----------------------------------------------------------
  validates :site_id, :presence => true
  validates_attachment_presence :file
  
  validates_uniqueness_of :file_file_name,
    :scope => :site_id
  
  # -- Callbacks ------------------------------------------------------------
  before_save :assign_label
  
protected
  
  def assign_label
    self.label = self.label.blank?? self.file_file_name.gsub(/\.[^\.]*?$/, '').titleize : self.label
  end
  
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.4.5 app/models/cms/file.rb
comfortable_mexican_sofa-1.4.4 app/models/cms/file.rb
comfortable_mexican_sofa-1.4.3 app/models/cms/file.rb
comfortable_mexican_sofa-1.4.2 app/models/cms/file.rb
comfortable_mexican_sofa-1.4.1 app/models/cms/file.rb
comfortable_mexican_sofa-1.4.0 app/models/cms/file.rb