Slug generated having two hyphens at the end in rails 3.2 using friendly id?

89 views Asked by At

I am using friendly_id 4.0.10.1 gem for generating slug. I am using two columns to generate slug: first_name and last_name.

The last_name value can be empty. The problem arises in these cases:

   first_name  last_name  slug
1. Arun          Kumar    arun-kumar
2. Arun          Kumar    arun-kumar--2
3. Arun          Kumar    arun-kumar--3

I am expecting the slug to be like this: arun-kumar-2, arun-kumar-3.

I do not want those double hyphens to appear at the end. How to avoid that?

1

There are 1 answers

5
TK-421 On BEST ANSWER

See this issue, and the linked docs:

https://github.com/norman/friendly_id/issues/170

The "--" is used to separate the slug from the sequence. This allows you to have a slug with a number in it.

You can configure sequence_separator.