Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails redirects to 'data:,'

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
like image 435
chendriksen Avatar asked Sep 04 '13 17:09

chendriksen


1 Answers

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.

like image 151
chendriksen Avatar answered Nov 13 '22 00:11

chendriksen