Sha256: 731a2ca367258c6be577c7fb6a51c31b6cd45d11a2cd4eef8cefe02996180e9a
Contents?: true
Size: 496 Bytes
Versions: 111
Compression:
Stored size: 496 Bytes
Contents
class ScopeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) id_method = "#{attribute}_id".to_sym valid_collection = "valid_#{attribute.to_s.pluralize}".to_sym 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
111 entries across 111 versions & 1 rubygems