Voglio ottenere oggetto String da ActiveSupport :: SafeBuffer. Il metodo to_s restituisce lo stesso tipo di ActiveSupport :: SafeBuffer. Solo to_sym.to_s restituisce String, ma questo è più di un trucco. Ecco la mia console di gioco:Come convertire ActiveSupport :: SafeBuffer in String?
irb(main):008:0> s = ActiveSupport::SafeBuffer.new("asdf")
# => "asdf"
irb(main):009:0> s.class
# => ActiveSupport::SafeBuffer
irb(main):010:0> s.to_s.class
# => ActiveSupport::SafeBuffer
irb(main):011:0> s.to_sym.to_s
# => "asdf"
irb(main):012:0> s.to_sym.to_s.class
# => String
Cosa stai cercando di fare? 'SafeBuffer' _è_ una stringa già. – matt