简体   繁体   中英

Rails: FriendlyID Japanese slugs

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM