I'm using the gem 'friendly_id', '~> 5.0.0
and I just want to use the old behaviour which is appending a number sequence count in the slug instead of UUID
.
for example
>> test-slug-2
>> test-slug-3
>> test-slug-4
I was able to make this using: config/initializers/slugged.rb
module FriendlyId::Slugged
def resolve_friendly_id_conflict(candidates)
column = friendly_id_config.slug_column
separator = friendly_id_config.sequence_separator
slug = normalize_friendly_id(candidates.first)
sequence = self.class.where("#{column} like '#{slug}#{separator}%'").count + 2
"#{slug}#{separator}#{sequence}"
end
end
and in my model
extend FriendlyId
friendly_id :name, use: [:slugged, :finders]
However when I have a test-slug-3
and test-slug-4
and tried to delete the test-slug-3
the next time I create a record it will generate a slug which is test-slug-4
which is having an error in my end because
Slug is already taken.