Sha256: dec6f19fd4903741754e974e78addef8e4d496ad0855cd7cc226493406df4867
Contents?: true
Size: 691 Bytes
Versions: 4
Compression:
Stored size: 691 Bytes
Contents
module Locomotive module Concerns module Shared module Slug extend ActiveSupport::Concern module ClassMethods def slugify_from(field) class_eval <<-EOV before_validation { |object| object.send(:normalize_slug, :#{field.to_s}) } EOV end end protected def normalize_slug(field) value = self.send(field) if self.slug.blank? && value.present? self.slug = value.clone end return unless self.slug.present? site&.allow_dots_in_slugs ? self.slug.pathify! : self.slug.permalink! end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems