Sha256: f1aefc7576d5f85ffd3097c520b916b9ac6de97d9680b5d823e5d9c0112d8f41

Contents?: true

Size: 799 Bytes

Versions: 5

Compression:

Stored size: 799 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

5 entries across 5 versions & 1 rubygems

Version Path
introspective_grape-0.3.2 spec/dummy/app/models/image.rb
introspective_grape-0.3.1 spec/dummy/app/models/image.rb
introspective_grape-0.3.0 spec/dummy/app/models/image.rb
introspective_grape-0.2.9 spec/dummy/app/models/image.rb
introspective_grape-0.2.8 spec/dummy/app/models/image.rb