Skip to content

Instantly share code, notes, and snippets.

@uberllama
uberllama / gist:6977242
Last active December 25, 2015 12:29
Modified DelayedJob workflow to use the Document's ID rather than serializing the entire Document object.
class Document < ActiveRecord::Base
# Environment-specific direct upload url verifier screens for malicious posted upload locations.
DIRECT_UPLOAD_URL_FORMAT = %r{\Ahttps:\/\/s3\.amazonaws\.com\/myapp#{!Rails.env.production? ? "\\-#{Rails.env}" : ''}\/(?<path>uploads\/.+\/(?<filename>.+))\z}.freeze
belongs_to :user
has_attached_file :upload
validates :direct_upload_url, presence: true, format: { with: DIRECT_UPLOAD_URL_FORMAT }