Module: Arkaan::Concerns::Sluggable::ClassMethods
- Defined in:
- lib/arkaan/concerns/sluggable.rb
Overview
Module holding the class methods for the classes including this concern.
Instance Method Summary collapse
-
#make_sluggable ⇒ Object
Add the field and its validations in the model including it.
Instance Method Details
#make_sluggable ⇒ Object
Add the field and its validations in the model including it.
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/arkaan/concerns/sluggable.rb', line 14 def make_sluggable # @!attribute [rw] slug # @return [String] the slug of the current entity, in snake-case. field :slug, type: String validates :slug, length: { minimum: 4, message: 'minlength', if: :slug? }, format: { with: /\A[a-z]+(_[a-z]+)*\z/, message: 'pattern', if: :slug? }, uniqueness: { message: 'uniq', if: :slug? }, presence: { message: 'required' } end |