Sha256: e712ccc145a4aa3c26b5ad1c427e2d7486412814f1d462d539342875ac7a64e6
Contents?: true
Size: 1.17 KB
Versions: 1
Compression:
Stored size: 1.17 KB
Contents
module Cambium class Document < ActiveRecord::Base # ------------------------------------------ Plugins include PgSearch multisearchable :against => [:title] has_paper_trail dragonfly_accessor :upload # ------------------------------------------ Scopes scope :last_created, -> { order(:created_at => :desc) } # ------------------------------------------ Validations validates :title, :upload, :presence => true # ------------------------------------------ Instance Methods def to_s title end def image? ['jpg','jpeg','gif','png'].include?(upload.ext.downcase) end def pdf? upload.ext.downcase == 'pdf' end def has_thumb? thumb_url.present? end def thumb_url return image_url(300, 300) return png_cover_image_url(300, 300) if pdf? nil end def image_url(width, height) upload.thumb("#{width}x#{height}##{upload_gravity}").url end def png_cover_image_url(width, height) upload.thumb("#{width}x#{height}##{upload_gravity}", :format => 'png', :frame => 0).url end def ext upload.ext end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
cambium-1.3.0 | app/models/cambium/document.rb |