Sha256: efc213fe4b59e8039748800bf161d05d5edac1cdfb005e144bd59e4c3daac7fc
Contents?: true
Size: 646 Bytes
Versions: 15
Compression:
Stored size: 646 Bytes
Contents
module Locomotive module Extensions 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 if self.slug.present? self.slug.permalink! end end end end end end
Version data entries
15 entries across 15 versions & 1 rubygems