While querying and API that responds in XML an interesting element arises when tracking in the console data fictitious, layout not:
<address>SUTTER 10821
1032 LALALAND</address>
the parsing is being run by httparty
ruby gem.
The line break in the string is saved as \n
in a text datatype. Yet, when rendering in rails with .html_safe
, no new line is rendered.
What is the best way to process tha address attribute at moment of writing the record?
You can use string manipulation, like
record.address = xml_address.gsub("\n", "<br>")