2015-12-11 15:26:51 -05:00
|
|
|
# validators/sluguuidless_validator.rb
|
2015-08-06 15:10:31 -04:00
|
|
|
class SluguuidlessValidator < ActiveModel::EachValidator
|
|
|
|
def validate_each(record, attribute, value)
|
|
|
|
if record.slug.match /([a-z0-9]+\-){4}[a-z0-9]+\z/
|
2015-12-11 15:26:51 -05:00
|
|
|
record.errors[attribute] << "#{value} must be unique"
|
2015-08-06 15:10:31 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|