3

I have a blog app that use Friendly_id gem and but when I use Arabic Character in the title and go to article show I have a URL like this http://www.blog.com/articles/8. but I want to get URL which is mapped to Arabic letters, how can I do it

Loenvpy
  • 899
  • 1
  • 10
  • 30
  • Possible duplicate question. Please use this answer. http://stackoverflow.com/questions/16855883/friendlyid-korean-slugs – Benjamin Apr 25 '14 at 14:29
  • @Benjamin This is NOT a duplicate question. Actually, It is a totally different matter. The question you references answers the issue of mapping Korean url to its english equivalent. Where as, in this question the user is trying to maintain proper representation of arabic characters in the url. – moeabdol Jun 12 '15 at 00:32

1 Answers1

0

You can override normalize_friendly_id.
It generates slug directly from article.title.

class Article < ActiveRecord:Base

extend FriendlyId
friendly_id :title, use: :slugged

def normalize_friendly_id(string)
  string
end

However, make sure to handle characters manually.
(ex. replace special characters to be url-safe : Safe characters for friendly url)

Community
  • 1
  • 1
foloinfo
  • 631
  • 8
  • 19