Displaying line breaks & paragraphs using 'simple_format' ?

Hey Tom-

sadly I noticed this same issue with simple_format

I get around it by adding a model method to whatever the class is with the text. For example, if I have pages, and each page has a body, I'll add a method like so:

class Page   def format_breaks     body.gsub("\n", "<br />")   end end

and then call @page.body.format_breaks in the view.

This might lead to performance issues if you have an awful lot of text though so it might be more efficient to create an after_save callback instead.

Something like:

class Page   after_save :format_breaks   def format_breaks      update_attribute :body, body.gsub("\n", "<br />")   end end

This will update the entry in the database after you save so all you have to call in the view is <%= @page.body %>

Note - to keep your XHTML valid, you'll need to wrap the whole thing in paragraph tags (I believe?)

<p>   <%= @page.body %> </p>

Hope that helps?

Thanks, Gavin! That definitely helps...