8 lines
227 B
Ruby
8 lines
227 B
Ruby
|
class SluguuidlessValidator < ActiveModel::EachValidator
|
||
|
def validate_each(record, attribute, value)
|
||
|
if record.slug.match /([a-z0-9]+\-){4}[a-z0-9]+\z/
|
||
|
record.errors[attribute] << 'must be unique'
|
||
|
end
|
||
|
end
|
||
|
end
|