Hi! I''ve got a form for creating news and i''d like to keep formatting of the text in the textarea - if user presses enter twice, or presses space ten times it should be visible when editing or showing the news. Probably i should add before_save filter and some regexps for adding html tags, but i know almost nothing about regexp. Maybe there''s a simpler way also. -- Posted via http://www.ruby-forum.com/.
Ćukasz Piestrzeniewicz
2006-Mar-09 12:26 UTC
[Rails] How to keep formatting of text in textarea?
On 09/03/06, szymek <g0nzo@o2.pl> wrote:> I''ve got a form for creating news and i''d like to keep formatting of the > text in the textarea - if user presses enter twice, or presses space ten > times it should be visible when editing or showing the news. > > Probably i should add before_save filter and some regexps for adding > html tags, but i know almost nothing about regexp. Maybe there''s a > simpler way also.Use RedCloth (http://whytheluckystiff.net/ruby/redcloth/) :) Install RedCloth gem (preferably version 3.0.3 as 3.0.4 is somewhat broken). Then when presenting contents of field use textilize() helper like this: <%= textilize(@item.description) %> -- ?ukasz Piestrzeniewicz http://ragnarson.blogspot.com