TextHelpers in Controller?


#1

I have a controller that saves info to the DB. It’s based on the AJAX
scaffolding code. All I want to do is add a simple_format() function to
it before I save a user-edited text field to the DB. TO convert line
returns to
s, etc.

@project_note = ProjectNote.new(params[:project_note])
@project_note.body = simple_format(@project_note.body)

Since this happens in a controller, I guess it’s not kosher to use
viewer code, and Rails doesn’t let me. (Some interesting discussions
back from January 05 in the mail archives). I see lots of examples of
how to use helper :my_helper in a controller, with MY own generated
helpers, but how can I use the core API TextHelper suite?

err… and is there an opposite to simple_format, that converts
s
into line returns? regex would be simple enough of course, but if
somebody already wrote it into the API… (Yes, I did check the API as
far as I could).

TIA,

Micah