ensure external is not deleted when converting
This commit is contained in:
parent
6c07ab3065
commit
9b8139f5f4
@ -170,7 +170,7 @@ class ApplicationController < ActionController::Base
|
|||||||
readonly
|
readonly
|
||||||
when PG::Error
|
when PG::Error
|
||||||
render_error_page(503, exception, message: "The database is unavailable. Try again later.")
|
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)
|
render_expected_error(400, exception.message)
|
||||||
when ActionController::RoutingError
|
when ActionController::RoutingError
|
||||||
render_error_page(405, exception)
|
render_error_page(405, exception)
|
||||||
|
@ -14,6 +14,7 @@ class ExternalAPIImage < ApplicationRecord
|
|||||||
belongs_to :api_image
|
belongs_to :api_image
|
||||||
|
|
||||||
validates :site, inclusion: { in: SITES.map(&:value) }
|
validates :site, inclusion: { in: SITES.map(&:value) }
|
||||||
|
validate :not_deleted, on: :create
|
||||||
|
|
||||||
enum site: SITES.to_h { |s| [s.value, s.value] }
|
enum site: SITES.to_h { |s| [s.value, s.value] }
|
||||||
|
|
||||||
@ -159,4 +160,11 @@ class ExternalAPIImage < ApplicationRecord
|
|||||||
|
|
||||||
include CacheMethods
|
include CacheMethods
|
||||||
include DataMethods
|
include DataMethods
|
||||||
|
|
||||||
|
def not_deleted
|
||||||
|
if is_deleted?
|
||||||
|
errors.add(:external_id, "is deleted")
|
||||||
|
throw(:abort)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user