module Tenon
  class ItemAsset < ActiveRecord::Base
    # Validations
    validates_presence_of :asset
    validates_presence_of :item

    # Relationships
    belongs_to :asset
    belongs_to :item, polymorphic: true

    accepts_nested_attributes_for :asset

    after_save :reprocess_asset

    def reprocess_asset
      asset.reload.attachment.reprocess! if asset_id_changed?
    end
  end
end

module Tenon
  class ItemAsset < ActiveRecord::Base
    # Validations
    validates_presence_of :asset

    # Relationships
    belongs_to :asset
    belongs_to :item, polymorphic: true

    accepts_nested_attributes_for :asset

    after_save :reprocess_asset

    def reprocess_asset
      asset.reload.attachment.reprocess! if asset_id_changed?
    end
  end
end

Remove the requirement of an item on ItemAssets to allow them to be saved before the item is saved
Remove the requirement of an item on ItemAssets to allow them to be saved before the item is saved
