简体   繁体   English

防止用户多次发布帖子

[英]Prevent user from posting a post multiple times

I have a simple app. 我有一个简单的应用程序。 User can make a post and after clicking the add button gets redirected to the list of posts. 用户可以发布帖子,然后单击添加按钮将重定向到帖子列表。

But after this if user clicks back arrow in his browser he's redirected back to the new post path with the content that he's already submitted. 但是在此之后,如果用户单击浏览器中的后退箭头,他将被重定向回具有他已提交内容的新帖子路径。 And he can submit it again. 他可以再次提交。

How to prevent user from doing this? 如何防止用户这样做?

i'm using devise 我正在使用设计

set a cookie like so: 像这样设置一个cookie:

cookies[:posted] = { :value => true, :expires => Time.now + 3600}

when the post is submitted. 帖子提交时。

and on the posting page check to see if that cookie is set, if so disable submit button? 并在发布页面上检查是否设置了该cookie,是否禁用了提交按钮?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM