ensure external is not deleted when converting

This commit is contained in:
Donovan Daniels 2024-10-24 04:36:59 -05:00
parent 6c07ab3065
commit 9b8139f5f4
Signed by: Donovan_DMC
GPG Key ID: 907D29CBFD6157BA
2 changed files with 9 additions and 1 deletions

View File

@ -170,7 +170,7 @@ class ApplicationController < ActionController::Base
readonly
when PG::Error
render_error_page(503, exception, message: "The database is unavailable. Try again later.")
when ActionController::ParameterMissing, ActionController::UnpermittedParameters
when ActionController::ParameterMissing, ActionController::UnpermittedParameters, ActiveRecord::RecordInvalid
render_expected_error(400, exception.message)
when ActionController::RoutingError
render_error_page(405, exception)

View File

@ -14,6 +14,7 @@ class ExternalAPIImage < ApplicationRecord
belongs_to :api_image
validates :site, inclusion: { in: SITES.map(&:value) }
validate :not_deleted, on: :create
enum site: SITES.to_h { |s| [s.value, s.value] }
@ -159,4 +160,11 @@ class ExternalAPIImage < ApplicationRecord
include CacheMethods
include DataMethods
def not_deleted
if is_deleted?
errors.add(:external_id, "is deleted")
throw(:abort)
end
end
end