Rails remove parent HTML tag

Posted by gshankar on Stack Overflow See other posts from Stack Overflow or by gshankar
Published on 2010-03-09T00:17:57Z Indexed on 2010/03/09 0:21 UTC
Read the original article Hit count: 622

Filed under:
|

It's pretty easy to sanitize HTML and strip ALL instances of a HTML tag using Rails helpers...

But how do you just remove ONE tag? In this case, I'm using a WYSIWYG editor that insists on wrapping all my text in a <p> tag. I want to remove this parent tag without stripping out any other <p> tags within the content of the text.

I know I could do this in JQuery really easily but I feel like this should be done server-side in my controller before I save the text.

Is there a way to do this?

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about html