module ManualSlug::Mongoid::ClassMethods
Public Instance Methods
manual_slug(_field, options = {}, callback = true)
click to toggle source
# File lib/manual_slug/mongoid.rb, line 19 def manual_slug(_field, options = {}, callback = true) options.merge!({ permanent: true, history: true, scope: (Hancock.config.mongoid_single_collection ? :_type : nil) }) slug _field, options #overwrite for default value field :_slugs, type: Array, localize: options[:localize], default: [], overwrite: true # we will create slugs manually when needed skip_callback :create, :before, :build_slug before_validation do self._slugs = self._slugs.map{ |s| s.strip }.reject {|s| s.blank? } if self._slugs if self._slugs.blank? self.build_slug end true end if callback end