kirqe
kirqe

Reputation: 2470

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

Upvotes: 0

Views: 135

Answers (1)

Brian McCall
Brian McCall

Reputation: 1907

set a cookie like so:

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?

Upvotes: 1

Related Questions