rails 重定向到“数据:," [英] rails redirects to 'data:,'

查看:37
本文介绍了rails 重定向到“数据:,"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我将 HTML 的输入保存为页面",如下所示:

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

但是如果您在标签中包含功能,它会说它已呈现页面,但实际上它什么都不返回,URL 栏显示data:,"

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:,'

奇怪的是,如果你找到@page.unique,然后访问它,例如localhost:3000/SKkFrA 页面呈现良好.

Strangely, if you find the @page.unique, and visit it afterwards, e.g. localhost:3000/SKkFrA the page renders fine.

有什么建议吗?

附言这是我正在使用的 show 方法:

p.s. Here's the show method I'm using:

def show
  @page = Page.find_by(unique: params[:id])
  render :text => @page.html
end

推荐答案

我在 IRC 上找到了答案.

I found the answer on IRC.

这是一项安全功能,新页面的 HTML 内容与提交表单的 HTML 内容相匹配,Chrome 会阻止.

This is a security feature, the HTML content of the new page matches the HTML content of the submitted form, which Chrome blocks.

这篇关于rails 重定向到“数据:,"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆