Title / Description
Code class ItemImage < ApplicationRecord PROCESS_JOB = FileProcessJob belongs_to :item has_attached_file :file validates_attachment_presence :file, unless: :processing? validates_attachment_content_type :file, content_type: /\Aimage\/.*\z/, if: :file_present? after_commit :process_file_async, on: [:create, :update], if: :should_be_processed? scope :processed, -> { where.not(file_file_name: nil) } scope :unprocessed, -> { where(file_file_name: nil) } def processing? !processed? end end
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code