Forum: Ruby on Rails TextHelpers in Controller?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
602f73f02a8b8abcf01ca093e1762006?d=identicon&s=25 Micah Bly (yak)
on 2006-03-02 00: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 = 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 <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).

TIA,

Micah
This topic is locked and can not be replied to.