Sha256: 845169f7296d0dc95e5545a7afc596c52291e2fc8b7b3473e137e61eace297a0

Contents?: true

Size: 779 Bytes

Versions: 9

Compression:

Stored size: 779 Bytes

Contents

module Cms
  class Asset < ActiveRecord::Base
    set_table_name 'cms_assets'

    has_attached_file :asset,
      :styles => { :tiny => '50x50>', :thumb => '100x100>' }, #:custom => Proc.new { |instance| "#{instance.photo_width}x#{instance.photo_height}>" } },
      :path => ":rails_root/public/cms/assets/:id/:style/:filename",
      :url => "/cms/assets/:id/:style/:filename"

    validates_attachment_presence :asset

    named_scope :ordered, :order => 'asset_file_name ASC'

    before_post_process :process_check

    def to_s
      asset_file_name
    end

    def image?
      !(asset_content_type =~ /^image.*/).nil?
    end

    def icon?
      !(asset_content_type =~ /icon$/).nil?
    end

  protected
    def process_check
      image? && !icon?
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
liquid_cms-0.2.0.9 app/models/cms/asset.rb
liquid_cms-0.2.0.8 app/models/cms/asset.rb
liquid_cms-0.2.0.7 app/models/cms/asset.rb
liquid_cms-0.2.0.6 app/models/cms/asset.rb
liquid_cms-0.2.0.5 app/models/cms/asset.rb
liquid_cms-0.2.0.4 app/models/cms/asset.rb
liquid_cms-0.2.0.3 app/models/cms/asset.rb
liquid_cms-0.2.0.2 app/models/cms/asset.rb
liquid_cms-0.2.0 app/models/cms/asset.rb