Created
October 30, 2016 00:24
-
-
Save anonymous/6c98534fb5508bb378dad680649b7175 to your computer and use it in GitHub Desktop.
Prevent Users from Submitting duplicate forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
protect_from_forgery with: :exception | |
private | |
def client_will_not_cache_response | |
response.headers["Cache-Control”] = “no-cache, no-store” | |
response.headers[“Pragma”] = “no-cache” | |
response.headers[“Expires”] = “Fri, 01 Jan 1990 00:00:00 GMT” | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PuppiesController < ApplicationController | |
before_filter :redirect_if_existing, only: [:new, :create] | |
after_filter :browser_will_not_cache_response, only: [:new] | |
private | |
def redirect_if_existing | |
## If user already has a record in the puppies table | |
## created this year | |
## then redirect them to edit that Puppy. | |
## Be a courteous host and alert user that they were redirected. | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I meant to create this under my account @rskelley9