Sha256: 4be62394841e90dc8b773e92b66a186f12e5eefa56e049fa691c7df0d05f7b8c

Contents?: true

Size: 327 Bytes

Versions: 16

Compression:

Stored size: 327 Bytes

Contents

class SlugValidator < ActiveModel::Validator
	def validate(record)
    	if Dimensions::Slug.where(value: record.value, slugable_type: record.slugable_type).any?
			record.errors.add(:slug, "is already in use, chose another one.")
		end
	end
end

module Dimensions
	class Slug < Dimension
		validates_with SlugValidator
	end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
iatelier-0.5.2 lib/iatelier/models/dimensions/slug.rb
iatelier-0.5.1 lib/iatelier/models/dimensions/slug.rb
iatelier-0.5.0 lib/iatelier/models/dimensions/slug.rb
iatelier-0.4.4 lib/iatelier/models/dimensions/slug.rb
iatelier-0.4.3 lib/iatelier/models/dimensions/slug.rb
iatelier-0.4.2 lib/iatelier/models/dimensions/slug.rb
iatelier-0.4.1 lib/iatelier/models/dimensions/slug.rb
iatelier-0.4.0 lib/iatelier/models/dimensions/slug.rb
iatelier-0.3.2 lib/iatelier/models/dimensions/slug.rb
iatelier-0.3.1 lib/iatelier/models/dimensions/slug.rb
iatelier-0.3.0 lib/iatelier/models/dimensions/slug.rb
iatelier-0.1.8 lib/iatelier/models/dimensions/slug.rb
iatelier-0.1.7 lib/iatelier/models/dimensions/slug.rb
iatelier-0.1.5 lib/iatelier/models/dimensions/slug.rb
iatelier-0.1.4 lib/iatelier/models/dimensions/slug.rb
iatelier-0.1.3 lib/iatelier/models/dimensions/slug.rb