mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-05 04:03:45 +08:00
Fix position validation [SCI-11050]
This commit is contained in:
parent
98415c0d8d
commit
d6ca444f4a
1 changed files with 3 additions and 3 deletions
|
@ -28,8 +28,8 @@ class StorageLocationRepositoryRow < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def ensure_uniq_position
|
def ensure_uniq_position
|
||||||
if StorageLocationRepositoryRow.where(storage_location: storage_location)
|
if storage_location.storage_location_repository_rows
|
||||||
.where('metadata @> ?', { position: metadata['position'] }.to_json)
|
.where("metadata->>'position' = ?", metadata['position'].to_json.gsub(',', ', '))
|
||||||
.where.not(id: id).exists?
|
.where.not(id: id).exists?
|
||||||
errors.add(:base, I18n.t('activerecord.errors.models.storage_location.not_uniq_position'))
|
errors.add(:base, I18n.t('activerecord.errors.models.storage_location.not_uniq_position'))
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue