Forum: Ruby on Rails remove html tags from string in controller, how?

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.
paul (Guest)
on 2007-01-04 19:26
Been searching for a function that can do this, but have onl found a
helper function.

is there a way to strip all html tags of a string in a controller?

Thanks
Alex W. (Guest)
on 2007-01-04 19:53
paul wrote:
> Been searching for a function that can do this, but have onl found a
> helper function.
>
> is there a way to strip all html tags of a string in a controller?
>
> Thanks

This should work

  class SomeController < AC::B
    include ActionView::Helpers::TextHelper

    def foo
      @escaped_string = strip_tags('<h1>Foo</h1>')
    end

  end
paul (Guest)
on 2007-01-04 20:10
cool, thanks :-)
This topic is locked and can not be replied to.