在我的应用程序中,我将 HTML 输入保存为“页面”,如下所示:
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 栏显示“数据:,”
奇怪的是,如果你找到@page.unique,然后访问它,例如localhost:3000/SKkFrA 页面呈现良好。
有什么建议?
附言这是我正在使用的 show 方法:
def show
@page = Page.find_by(unique: params[:id])
render :text => @page.html
end
最佳答案
我在 IRC 上找到了答案。
这是一项安全功能,新页面的 HTML 内容与提交表单的 HTML 内容相匹配,Chrome 会阻止这些内容。
关于ruby-on-rails - rails 重定向到 'data:,',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18620118/