I'm building an ecommerce app in Rails 4. After I submit an order, I get to a thank you page. When I hit the back button, I get taken back to the order form with all data filled in, including credit card info. So if I hit submit again, a new order gets placed.
When the user hits the back button, how do I delete all form data. That would suffice because if the user enters all their information again, it's not an accidental order.
Any other recommended ways to solve this?
Here is part of the form code..
<%= f.text_field :cardname %>
<%= f.text_field :address %>
<%= f.text_field :address2 %>
<%= f.text_field :city %>
<%= f.select(:state, options_for_select(us_states, f.object.state), {prompt: "Select"}) %>
<%= f.text_field :zip %>
<%= text_field_tag :card_number, nil, { :name => nil, :'data-stripe' => "number" %>
<%= text_field_tag :card_code, nil, { :name => nil, :'data-stripe' => "cvc" } %>
<%= select_month nil, { use_two_digit_numbers: true }, { :name => nil, :'data-stripe' => "exp-month" } %>
<%= select_year nil, { start_year: Date.today.year, end_year: Date.today.year+10 }, { :name => nil, :'data-stripe' => "exp-year" } %>
<%= f.submit "Confirm Order" %>
UPDATE: Based on this other question, I entered the below code in my order controller. This code gives the user some warnings so it helps. But the user can click ok on the warning dialog and go back to the order page and the info still shows up in the form. Is there a simple way to erase cache on the order form when a user hits the back button?
before_filter :set_cache_buster
def set_cache_buster
response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
response.headers["Pragma"] = "no-cache"
response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
end