Sha256: 1d38c20c3379cbdd6b7b93164c23a844798651f6ed979aecc5dbadc2c4555ca0

Contents?: true

Size: 680 Bytes

Versions: 7

Compression:

Stored size: 680 Bytes

Contents

module Tandem
  class Image < ActiveRecord::Base

    THUMB_WIDTH = 150
    THUMB_HEIGHT = 150

    has_attached_file :resource, Tandem::Configuration.paperclip_options

    validates_attachment_presence :resource
    validates_attachment_size :resource, :less_than => 1.megabyte
    validates_attachment_content_type :resource, :content_type => ['image/gif', 'image/jpg', 'image/jpeg', 'image/png']

    has_many :content_images, class_name: 'Tandem::Content::Image'

    default_scope order('created_at DESC')

    attr_accessible :resource

    def thumb_url
      resource.url(:thumb)
    end

    def as_json(options={})
      super(:methods => :thumb_url)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tandem-0.2.5 app/models/tandem/image.rb
tandem-0.2.4 app/models/tandem/image.rb
tandem-0.2.3 app/models/tandem/image.rb
tandem-0.2.2 app/models/tandem/image.rb
tandem-0.2.1 app/models/tandem/image.rb
tandem-0.2.0 app/models/tandem/image.rb
tandem-0.2.0.rc app/models/tandem/image.rb