Skip to main content
Ask A Question
Notifications
You’re not receiving notifications from this thread.
Subscribe

simple_format and Embedded content

Rails • Asked by Tony

I currently have a part of my website where people can submit user generated articles. I use simple_format to retain the layout.

e.g.

<%= simple_format(@post.content %>

As more and more of the internet uses embedded content such as Instragram posts and YouTube videos I'd like to be able to allow my users to be able to add embedded content to their articles to make them look a bit more interesting. Obviously simple_format won't allow the content to be displayed. Apart from doing something like the following which would endanger my website to exploits - what could I do?

<%= simple_format(@post.content , {}, :sanitize => false) %>

I could use a form where someone submits part of an Instragram and YouTube link but I don't think it is a very good solution as I don't know in advance at what point someone might want to add the content or how many YouTube videos they might want to have embedded on the page.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 29,763+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.