This seems fairly straight forward, but I''m a newbie to rails. Can I just write a function and pass it the "comment.body" and have it return the "comment.body" with all of the <br /> into line feeds? def break_to_linefeed(text) text.gsub("<br />","%0") text end I don''t know what the line feed code is, but will something like this work? Or is there a better way (aside from using RedCloth)??? Thanks! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
ry an wrote:> This seems fairly straight forward, but I''m a newbie to rails. Can I > just write a function and pass it the "comment.body" and have it return > the "comment.body" with all of the <br /> into line feeds? > > def break_to_linefeed(text) > text.gsub("<br />","%0") > text > end > > I don''t know what the line feed code is, but will something like this > work? Or is there a better way (aside from using RedCloth)??? Thanks!I''M SORRY! I meant turning a line feed into a <br />. So just switch the gsub params, and that''s what I''m asking - Thanks! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
text.gsub("\n","<br />") \n means "newline". Max On 8/28/06, ry an <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > ry an wrote: > > This seems fairly straight forward, but I''m a newbie to rails. Can I > > just write a function and pass it the "comment.body" and have it return > > the "comment.body" with all of the <br /> into line feeds? > > > > def break_to_linefeed(text) > > text.gsub("<br />","%0") > > text > > end > > > > I don''t know what the line feed code is, but will something like this > > work? Or is there a better way (aside from using RedCloth)??? Thanks! > > I''M SORRY! I meant turning a line feed into a <br />. So just switch > the gsub params, and that''s what I''m asking - Thanks! > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
ry an <rails-mailing-list@...> writes:> > I''M SORRY! I meant turning a line feed into a <br />. So just switch > the gsub params, and that''s what I''m asking - Thanks! >You might like to look at the simple_format function Gareth --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---