> On Jan 25, 2019, at 6:00 AM, fugee ohu <[email protected]> wrote:
> 
> I wanna convert my news stories to use slug urls based on the :headline 
> column instead of id's but some of the rows contain special characters like 
> double quotes, exclamation points, do I need to gsub those out

An interesting theory, but FriendlyId already does this, quite elaborately. The 
logic that does the "dumbification" is delegated to ActiveSupport's 
parameterize method, which takes everything not-ASCII and transliterates it 
into ASCII, and replaces any run of whitespace with a single dash, and removes 
punctuation. Next, the slug is checked for duplicates with any existing record, 
and a UUID is appended if so. It's really quite well done and very settled 
code. I have been using FriendlyId for 8 years or more without encountering any 
error that wasn't my own mistake.

In another of your many threads, you mention that you are trying to create a 
slug out of the article's text, rather than the headline (as the documentation 
encourages). You may want to try starting from a truncated copy of the article 
text (or even following the directions) before you assume that FriendlyId is at 
fault here. I doubt that your article text will fit into the size constraints 
of a URL segment, particularly if you worry about IE users seeing the thing at 
all*'

Walter

*The entire URL, including prefix, host, port, and path, must be no more than 
1,024 characters ASCII in order to be visited by IE.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6BF9DAC6-6CDB-4245-9CD9-107A73457496%40wdstudio.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to