Sha256: 16231c9aae92dee5ca0dd8608babc4901801ffdeb36267037eb4e3749c3c416e
Contents?: true
Size: 484 Bytes
Versions: 27
Compression:
Stored size: 484 Bytes
Contents
class ScopeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) id_method = :"#{attribute}_id" valid_collection = :"valid_#{attribute.to_s.pluralize}" if record.send(id_method).present? # Don't allow users to assign the IDs of other teams' or users' resources to this attribute. unless record.send(valid_collection).exists?(id: record.send(id_method)) record.errors.add(id_method, :invalid) end end end end
Version data entries
27 entries across 27 versions & 1 rubygems