X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/a942e37250873d383bd885ba0dba70c63b3c073d..ed56c26720184ca3d07f452faf014e177f1a2c2f:/services/api/lib/has_uuid.rb diff --git a/services/api/lib/has_uuid.rb b/services/api/lib/has_uuid.rb index 06c7d0cacf..74d09e94e9 100644 --- a/services/api/lib/has_uuid.rb +++ b/services/api/lib/has_uuid.rb @@ -7,8 +7,18 @@ module HasUuid base.validate :validate_uuid base.before_create :assign_uuid base.before_destroy :destroy_permission_links - base.has_many :links_via_head, class_name: 'Link', foreign_key: :head_uuid, primary_key: :uuid, conditions: "not (link_class = 'permission')", dependent: :restrict - base.has_many :links_via_tail, class_name: 'Link', foreign_key: :tail_uuid, primary_key: :uuid, conditions: "not (link_class = 'permission')", dependent: :restrict + base.has_many(:links_via_head, + -> { where("not (link_class = 'permission')") }, + class_name: 'Link', + foreign_key: :head_uuid, + primary_key: :uuid, + dependent: :destroy) + base.has_many(:links_via_tail, + -> { where("not (link_class = 'permission')") }, + class_name: 'Link', + foreign_key: :tail_uuid, + primary_key: :uuid, + dependent: :destroy) end module ClassMethods @@ -45,7 +55,7 @@ module HasUuid end else if self.new_record? - self.errors.add(:uuid, "assignment not permittid") + self.errors.add(:uuid, "assignment not permitted") else self.errors.add(:uuid, "change not permitted") end