Skip to content

@leemcalilly /gist:cfda1a7f15d87dbab731 secret
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class Work < ActiveRecord::Base
attr_accessible :client, :client_ids, :date, :description, :featured, :image, :name, :service
validates_presence_of :date, :client_ids, :name
validates_length_of :description, :in => 5..500, :allow_blank => true
validates_length_of :name, :in => 5..50
has_many :postings
has_many :clients, :through => :postings
mount_uploader :image, ImageUploader
after_save :enqueue_image
def image_name
File.basename(image.path || image.filename) if image
end
def enqueue_image
ImageWorker.perform_async(id, key) if key.present?
end
class ImageWorker
include Sidekiq::Worker
def perform(id, key)
work = Work.find(id)
work.key = key
work.remote_image_url = work.image.direct_fog_url(with_path: true)
work.save!
work.update_column(:image_processed, true)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.