Sha256: bbb00180312e2c6b5e45de96c3eef62eb952df98cdc8d2579af1532201861aac

Contents?: true

Size: 797 Bytes

Versions: 1

Compression:

Stored size: 797 Bytes

Contents

require 'paperclip'
#require 'delayed_paperclip'
class Image < ActiveRecord::Base
  belongs_to :imageable, polymorphic: true

  has_attached_file :file, styles: {medium: "300x300>", thumb: "100x100"},
    url: "/system/:imageable_type/:imageable_id/:id/:style/:filename"

  validates_attachment :file, content_type: {content_type: ["image/jpeg", "image/png", "image/gif"]}
  validates_attachment_size :file, :less_than => 2.megabytes

  def medium_url
    file.url(:medium)
  end
  #process_in_background :file, processing_image_url: 'empty_avatar.png'

  Paperclip.interpolates :imageable_type  do |attachment, _style|
      attachment.instance.imageable_type.try(:pluralize)
  end
  Paperclip.interpolates :imageable_id  do |attachment, _style|
      attachment.instance.imageable_id
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
introspective_grape-0.3.3 spec/dummy/app/models/image.rb