app/models/spotlight/featured_image.rb in blacklight-spotlight-0.8.0 vs app/models/spotlight/featured_image.rb in blacklight-spotlight-0.8.1

- old
+ new

@@ -2,15 +2,11 @@ ## # Featured images for browse categories, feature pages, and exhibits class FeaturedImage < ActiveRecord::Base mount_uploader :image, Spotlight::FeaturedImageUploader - before_validation do - if document && document.uploaded_resource? - self.image = document.uploaded_resource.url.file - end - end + before_validation :set_image_from_uploaded_resource after_save do if image.present? image.cache! unless image.cached? image.store! @@ -31,8 +27,21 @@ if @document && document_global_id != @document.to_global_id.to_s @document = nil end @document ||= GlobalID::Locator.locate document_global_id + + rescue Blacklight::Exceptions::RecordNotFound => e + Rails.logger.info("Exception fetching record by id: #{document_global_id}") + Rails.logger.info(e) + + nil + end + + private + + def set_image_from_uploaded_resource + return unless document && document.uploaded_resource? + self.image = document.uploaded_resource.url.file end end end