Sha256: ab7d24bd9e0eb1546ce0f9401554567bcb72946f37d9eb9b43b157c36e4fac54

Contents?: true

Size: 696 Bytes

Versions: 13

Compression:

Stored size: 696 Bytes

Contents

class Image::Base < ActiveRecord::Base

  self.table_name = "images"
  mount_uploader :image, ImageUploader
  attr_accessor :crop_x, :crop_y, :crop_w, :crop_h

  # Associations
  belongs_to :imageable, :polymorphic => 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,
      "full_url" => image.url,
      "thumbnail_url" => image.thumb.url,
      "large_url" => image.large.url,
      "url" => "/admin/images/#{id}",
      "delete_type" => "DELETE"
    }
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
poodle-rb-0.2.5 spec/dummy/app/models/image/base.rb
poodle-rb-0.2.4 spec/dummy/app/models/image/base.rb
poodle-rb-0.2.3 spec/dummy/app/models/image/base.rb
poodle-rb-0.2.2 spec/dummy/app/models/image/base.rb
poodle-rb-0.2.1 spec/dummy/app/models/image/base.rb
poodle-rb-0.2.0 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.9 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.8 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.7 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.6 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.5 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.4 spec/dummy/app/models/image/base.rb
poodle-rb-0.1.3 spec/dummy/app/models/image/base.rb