module ActiveRecord::Validations::ClassMethods
Public Instance Methods
validates_globalized_uniqueness_of(*attr_names)
click to toggle source
Validates whether the value of the specified attributes are unique across the system. Useful for making sure that only one user can be named “davidhh”.
See validates_uniqueness_of in ActiveRecord::Validations::ClassMethods
for further explanation.
This validator works the same, but additionally respects globalize3 model translations. Also, you can use :locale as value for :scope.
For instance, if you want to validate that a product title is unique in each locale:
class Product < ActiveRecord::Base translates :title validates_globalized_uniqueness_of :title, :scope => :locale end
# File lib/active_record/validations/globalized_uniqueness.rb, line 129 def validates_globalized_uniqueness_of(*attr_names) validates_with GlobalizedUniquenessValidator, _merge_attributes(attr_names) end