Question

I have a blog app that use Friendly_id gem and but when I use Japanese 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 japanese letters or latin letters, how can i do it

Pas de solution correcte

Autres conseils

So there is this solution has been suggested: FriendlyID Korean slugs

however I tend to prefer a solution with : http://www.rubydoc.info/gems/unidecode

gem 'unidecode'
# ...
extend FriendlyId
friendly_id :nickname_ascii, use: :slugged
# using gem unidecode
def nickname_ascii
  nickname.to_ascii
end

Good enough for kana but quite bad for Kanji

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top