When I enter some text in a text_area with carriage returns and then
store the text in a database the carriage returns are preserved in the
db. When I get the string back the carriage returns are gone, replace by
spaces.
example.
if I enter :
blah
blah
blah
the db stores:
blah
blah
blah
when i show the record I get:
blah blah blah
I tried to split string by:
<% @day.food.split(''\r\n'').each do |line| %>
<%= line %><br/>
<%end%>
but it doesn''t work. The \r\n is there. I put a <% p line %> in
and
looked at the logs.
The string does not get split.
anyone help?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 16, 2010, at 9:06 PM, John Sayeau wrote:> I tried to split string by: > > > <% @day.food.split(''\r\n'').each do |line| %> > <%= line %><br/> > <%end%> > > but it doesn''t work. The \r\n is there. I put a <% p line %> in and > looked at the logs. > The string does not get split. > > anyone help?Try this: <%= simple_format( @day.food ) %> and see what you get then. Walter -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Dec 16, 9:06 pm, John Sayeau <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> When I enter some text in a text_area with carriage returns and then > store the text in a database the carriage returns are preserved in the > db. When I get the string back the carriage returns are gone, replace by > spaces. > example. > if I enter : > > blah > blah > blah > > the db stores: > > blah > blah > blah > > when i show the record I get: > > blah blah blah > > I tried to split string by: > > <% @day.food.split(''\r\n'').each do |line| %> > <%= line %><br/> > <%end%> > > but it doesn''t work. The \r\n is there. I put a <% p line %> in and > looked at the logs. > The string does not get split. >Single-quoted strings don''t do backslash interpolation - so the string you''re passing to split is: \r\n and not what you wanted. Double-quotes will do the right thing. --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.