I want to retrieve string from database with rails (Rails 2.3.8 andy jruby 1.6.5.1) that looks like “I am human”, but in a browser it always looks like “I am human”. There is no extra spaces in between. How can I keep extra spaces, or what is striping the string.
Operation is pretty simple, just pull a string and show it in view.
Thanks.
Nothing is stripping the string – it’s the semantics of HTML that is screwing you over. All consecutive spaces in HTML are rendered as a single space, unless explicitly prevented by a
<pre>element, or equivalent CSS rule (white-space). You can also keep your spaces if you convert them to another kind of space – a non-breaking space ( ) does not get collapsed.