Sha256: fb26cf7e55630f55f368e96b4032cb8f49a0480553bba4b294a321069cc4135f

Contents?: true

Size: 914 Bytes

Versions: 6

Compression:

Stored size: 914 Bytes

Contents

module ActiveadminSelleoCms
  class Asset < ActiveRecord::Base
    attr_protected :id
    attr_accessor :cover_width, :cover_height, :cover_resize_method

    acts_as_list :scope => [:assetable_type, :assetable_id]

    belongs_to :assetable, polymorphic: true

    has_attached_file :cover,
                      :url  => "/system/cms/covers/:id/:style_:basename.:extension",
                      :path => ":rails_root/public/system/cms/covers/:id/:style_:basename.:extension",
                      :styles => Proc.new{ |attachment| attachment.instance.image_sizes },
                      :default_style => :normal

    validates_attachment_size :cover, :less_than => 10.megabytes
    validates_presence_of :assetable

    def url(format=nil)
      data.url(format)
    end

    def image_sizes
      { :normal => "#{cover_width || 120}x#{cover_height || 90}#{cover_resize_method || ">"}" }
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activeadmin-selleo-cms-0.0.38 app/models/activeadmin_selleo_cms/asset.rb
activeadmin-selleo-cms-0.0.37 app/models/activeadmin_selleo_cms/asset.rb
activeadmin-selleo-cms-0.0.36 app/models/activeadmin_selleo_cms/asset.rb
activeadmin-selleo-cms-0.0.35 app/models/activeadmin_selleo_cms/asset.rb
activeadmin-selleo-cms-0.0.34 app/models/activeadmin_selleo_cms/asset.rb
activeadmin-selleo-cms-0.0.33 app/models/activeadmin_selleo_cms/asset.rb