2

我想将我所有的 url 存储在 readble utf8 中

class User < ActiveRecord::Base
  require 'addressable/uri'
  require 'idn'
  include IDN
  def service_url=(url)
    url = Addressable::URI.parse Addressable::URI.unescape(url)
    url.host = Idna.toUnicode url.host
    super url.to_s
  end
end

重构或更通用的宝石的任何提示?

4

0 回答 0