app/models/locomotive/concerns/content_entry/slug.rb in locomotivecms-4.1.1 vs app/models/locomotive/concerns/content_entry/slug.rb in locomotivecms-4.2.0.alpha1
- old
+ new
@@ -65,17 +65,17 @@
break unless self.slug_already_taken?
end
end
def similar_slug(slug)
- _last = self.class.where(_slug: /^#{slug}-?\d*$/i)
+ _last_slug = self.class.where(_slug: /^#{slug}-?\d*$/i)
.excludes(_id: self._id)
- .only(:_slug)
- .order_by(:_id.desc)
+ .order_by(:created_at.desc)
+ .pluck(:_slug)
.first
- if _last
- _last['_slug'][::Mongoid::Fields::I18n.locale.to_s]
+ if _last_slug
+ _last_slug[::Mongoid::Fields::I18n.locale.to_s]
else
nil
end
end