Forum: Ruby on Rails TextHelpers in Controller?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Micah B. (Guest)
on 2006-03-02 01:59
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 <br>s, etc.

@project_note =[: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 <br>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).


This topic is locked and can not be replied to.