Skip to content

Instantly share code, notes, and snippets.

@mikecmpbll
Last active August 29, 2015 14:09
Show Gist options
  • Save mikecmpbll/1415ae0202e22bf9168c to your computer and use it in GitHub Desktop.
Save mikecmpbll/1415ae0202e22bf9168c to your computer and use it in GitHub Desktop.
module ScopeValidators
extend ActiveSupport::Concern
module ClassMethods
def validates(*args)
options = args.extract_options!
if options.key?(:uniqueness)
case options[:uniqueness]
when Hash
options[:uniqueness].merge!(scope: :entity_id)
when TrueClass
options[:uniqueness] = { scope: :entity_id }
end
end
super(*args, options)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment