Module: Atreides::Base::Validation
- Included in:
- ContentPart, Feature, Page, Post
- Defined in:
- lib/atreides/base/validation.rb
Overview
Module providing common validations functionality.
Class Method Summary collapse
Class Method Details
.included(recipient) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/atreides/base/validation.rb', line 8 def self.included(recipient) recipient.class_eval do before_validation :update_slug # Sets the object's slug. Slugs are used to create SEO friendly URLs. def update_slug # Set slug if not set if respond_to?(:slug) and respond_to?(:title) self.slug = title? ? title.parameterize : id if !slug? or slug.match(/^\d+$/) end end end end |