Sha256: f99b2c5668904cc31d30bbae62f695ced1152dc2b0081cf173edda30198ff26f

Contents?: true

Size: 907 Bytes

Versions: 18

Compression:

Stored size: 907 Bytes

Contents

class Photo < ActiveRecord::Base
  include Positionable
  default_scope order(:position)

  validates_attachment :image, :presence => true,
    :size => { :in => 0..2.megabytes }

  has_attached :image, :processors => [:auto_orient, :thumbnail]
  
  acts_as_taggable

  validates_presence_of :photographable
  belongs_to :photographable, :polymorphic => :true
  delegate :url, :file_name, :to => :image
  
  field :caption, :text
  
  def owner
    photographable.owner if photographable && photographable.respond_to?(:owner)
  end
    
  timestamps

  def to_label
    image_file_name
  end
  
  # ============
  # = Rotation =
  # ============

  attr_accessor :rotation_degrees, :rotate
    
  def rotate!(degrees = 90)
    self.rotation_degrees ||= degrees
    self.rotate = true
    self.image.reprocess!
    self.save
  end
  
  def rotating?
    !self.rotation_degrees.nil? and self.rotate
  end

end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
fullstack-cms-0.3.28 app/models/photo.rb
fullstack-cms-0.3.27 app/models/photo.rb
fullstack-cms-0.3.26 app/models/photo.rb
fullstack-cms-0.3.25 app/models/photo.rb
fullstack-cms-0.3.24 app/models/photo.rb
fullstack-cms-0.3.23 app/models/photo.rb
fullstack-cms-0.3.22 app/models/photo.rb
fullstack-cms-0.3.21 app/models/photo.rb
fullstack-cms-0.3.20 app/models/photo.rb
fullstack-cms-0.3.19 app/models/photo.rb
fullstack-cms-0.3.18 app/models/photo.rb
fullstack-cms-0.3.17 app/models/photo.rb
fullstack-cms-0.3.16 app/models/photo.rb
fullstack-cms-0.3.15 app/models/photo.rb
fullstack-cms-0.3.14 app/models/photo.rb
fullstack-cms-0.3.13 app/models/photo.rb
fullstack-cms-0.3.12 app/models/photo.rb
fullstack-cms-0.3.11 app/models/photo.rb