Sha256: ad1489fecef532fe0630202932be1221b6470814130ef182b56338bb2bb2691e

Contents?: true

Size: 679 Bytes

Versions: 1

Compression:

Stored size: 679 Bytes

Contents

class Image::Base < ActiveRecord::Base

  self.table_name = "images"

  attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

  # Associations
  belongs_to :imageable, :polymorphic => true, optional: true

  # Callbacks
  after_save :crop_image

  def crop_image
    image.recreate_versions! if crop_x.present?
  end

  #one convenient method to pass jq_upload the necessary information
  def to_jq_upload
    {
      "name" => read_attribute(:image),
      "size" => image.size,
      "original_url" => image.url,
      "large_url" => image.large.url,
      "medium_url" => image.medium.url,
      "small_url" => image.small.url,
      "tiny_url" => image.tiny.url
    }
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
usman-0.1.0 app/models/image/base.rb