I am trying to convert slugs to normal characters before using it in Friendly ID, but it does not work:
class CompanyJob < ApplicationRecord
extend FriendlyId
def self.convert_slug(title)
n = title.downcase.to_s
n.gsub! /[àáạãâậấẫầăặắằẵ]/, "a"
n.gsub! /[đ]/, "d"
n.gsub! /[èéẹẽêềếệễ]/, "e"
n.gsub! /[óòọõôốồộỗơớợỡờ]/, "o"
n.gsub! /[úùụũưứựừữ]/, "u"
n.gsub! /[íịìĩ]/, "i"
n.gsub! /[ýỵỹỳ]/, "y"
return n
end
friendly_id CompanyJob.convert_slug(:title), use: :slugged
But, the resulting slug is the title unchanged by the convert function. Can anyone can help me solve this issue? Thanks so much!