From 6b6ad2f07f4772f5615dc8492c3ba870afb017c5 Mon Sep 17 00:00:00 2001 From: Johnny Shields <27655+johnnyshields@users.noreply.github.com> Date: Mon, 18 Sep 2023 05:21:11 +0900 Subject: [PATCH] Add note about indexes to README --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 0cceb57..358c613 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ post = Post.find 'a-thousand-plateaus' # Finds by slugs post = Post.find '50b1386a0482939864000001' # Finds by bson ids => ... ``` + [Examine slug.rb](lib/mongoid/slug.rb) for all available options. ### Updating Existing Records @@ -133,6 +134,23 @@ The `to_url` method comes from [stringex](https://github.com/rsl/stringex). You can define a slug builder globally and/or override it per model. +### Indexing + +By default, Mongoid Slug will automatically generate an index for the slug, which will be created when you run `rake db:create_indexes`. This index will take into account scoping and other options described below. + +To skip this index generation, you may set `index: false` as follows: + +```ruby +class Employee + include Mongoid::Document + include Mongoid::Slug + + field :name + + slug :name, index: :false +end +``` + ### Scoping To scope a slug by a reference association, pass `:scope`: