how i reinstate accented latin characters ruby?


i have an activerecord model, foo, name field. i'd users means hunt name, nonetheless i'd hunt replace box any accents. thus, i'm also storing canonical_name domain opposing search:



class foo
validates_presence_of :name

before_validate :set_canonical_name

private

def set_canonical_name
self.canonical_name ||= canonicalize(self.name) self.name
end

def canonicalize(x)
x.downcase. # something here
end
end


i need fill "something here" reinstate accented characters. there anything improved than



x.downcase.gsub(/[]/,'a').gsub(//,'ae').gsub(//, 'c').gsub(/[]/,'e')....


and, matter, given i'm flush 1.9, i can't put those unicode literals code. tangible unchanging expressions feeling many uglier.



Comments

Popular posts from this blog

list macos calm editors formula editors

how i practical urls indicate .aspx pages asp.net deployed an iis? (preferably but iis)

jaxb - xjc - reworking generated typesafe enum category members