Sha256: e94cd0dbb40cc3a615981d9811f76a1ca2b98701018b47d5e59847563cb5896a
Contents?: true
Size: 609 Bytes
Versions: 170
Compression:
Stored size: 609 Bytes
Contents
module ManualSlug::ActiveRecord extend ActiveSupport::Concern included do extend FriendlyId end def text_slug slug end def text_slug=(s) self.slug = s end module ClassMethods def manual_slug(field, options = {}, callback = true) friendly_id field, use: [:slugged, :finders] define_method(:should_generate_new_friendly_id?) do slug.blank? end skip_callback :validation, :before, :set_slug before_validation do if self.slug.blank? self.send(:set_slug) end true end if callback end end end
Version data entries
170 entries across 170 versions & 4 rubygems