From 8bcc3c340b5941a654221b7592c062a323932934 Mon Sep 17 00:00:00 2001 From: shields Date: Thu, 5 Aug 2021 00:41:45 +0900 Subject: [PATCH] #slug should not default to _id.to_s. This is inconsistent with the rest of the gem: - _slugs does not contain _id.to_s - clear_slug! sets slugs to [], so #slug will return nil in this case - it will be overwritten when saving - before saving, one would expect both slug and _slugs to be nil --- lib/mongoid/slug.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/mongoid/slug.rb b/lib/mongoid/slug.rb index 3b11fb56..3b6d3ab9 100644 --- a/lib/mongoid/slug.rb +++ b/lib/mongoid/slug.rb @@ -248,8 +248,7 @@ def to_param # @return [String] the slug, or nil if the document does not have a slug. def slug - return _slugs.last if _slugs - _id.to_s + _slugs.last if _slugs end def slug_builder