In my app, I'm saving an input of HTML as a 'page' like so:
def create
@page = Page.new(page_params)
@page.unique = loop do
random_unique = SecureRandom.urlsafe_base64(4)
break random_unique unless Page.where(unique: random_unique).exists?
end
@page.save
redirect_to "/#{@page.unique}"
end
but if you include functionality in the tags, it says it's rendered the page, but in fact it returns nothing, with the URL bar showing 'data:,'
Strangely, if you find the @page.unique, and visit it afterwards, e.g. localhost:3000/SKkFrA the page renders fine.
Any suggestions?
p.s. Here's the show method I'm using:
def show
@page = Page.find_by(unique: params[:id])
render :text => @page.html
end
I found the answer on IRC.
This is a security feature, the HTML content of the new page matches the HTML content of the submitted form, which Chrome blocks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With