No-cache issue Safari and Mozilla Firefox

Hi Folks,

I’m writing a multistep form with the the help of Ryan B.

http://railscasts.com/episodes/217-multistep-forms

but I want change a little the form after the confirmation redirect to
the notification page that appear to the user to communicate that the
form just filled out I want that the user can’t back with the ‘Browser
Back Button’ at the confirmation page (the previous page)

to explain better what I want for me:

A = is the confirmation page

B = is the notification page

Thanks to Google I found this page

http://blog.serendeputy.com/posts/how-to-prevent-browsers-from-caching-a-page-in-rails/

And to the application_controller.rb I put

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

so when the user is on B when click on the browser back button on Safari
a dialog box appear


Are you sure that you want send a form again?

To reopen this page Safari must resend a form. This might result in
duplicate purchases, comments, or other actions.

{Cancel Button} / {Send Button}


If the user click on the {Cancel Button} button stay in the page if
click on {Send Button} appear an Rails error page


NoMethodError in FormonlineController#create

undefined method `deep_merge!’ for nil:NilClass

Rails.root: /var/www/myappname

Application Trace | Framework Trace | Full Trace
app/controllers/formonline_controller.rb:24:in `create’
Request

Parameters:

{“utf8”=>“✓”,
“authenticity_token”=>“Q/p7DxoyeTO8A94qEeHBkvsaAFKIVwMBadHYTDipxDM=”,
“formonline”=>{“richiedente”=>“safas”,
“email”=>“[email protected]”},
“commit”=>“Continue”}


on the 24 raw of form online


  1. def create

  2. session[:formonline_params].deep_merge!(params[:formonline]) if
    params[:formonline]

  3. @formonline = Formonline.new(session[:formonline_params])

  4. @formonline.current_step = session[:formonline_step]

  5. if @formonline.valid?
    28 if params[:back_button]
    29 …


Instead in the MOZILLA FIREFOX in the page appear a message


Document Expired

This document is no longer available.

The requested document is not available in Firefox’s cache.As a security
precaution, Firefox does not automatically re-request sensitive
documents.Click Try Again to re-request the document from the website.

{Try Again Button}


After the user click ok {Try Again Button} receive the same error
message on Safari with the Rails error page


NoMethodError in FormonlineController#create

undefined method `deep_merge!’ for nil:NilClass

Rails.root: /var/www/myappname

Application Trace | Framework Trace | Full Trace
app/controllers/formonline_controller.rb:24:in `create’
Request

Parameters:

{“utf8”=>“✓”,
“authenticity_token”=>“Q/p7DxoyeTO8A94qEeHBkvsaAFKIVwMBadHYTDipxDM=”,
“formonline”=>{“richiedente”=>“safas”,
“email”=>“[email protected]”},
“commit”=>“Continue”}


MY ISSUE

Is possible that the User when click on the back button stay on the same
page?

I hope my issue is clear and thank you in advance

Cluter

On Thu, Feb 16, 2012 at 21:35, Cluter V. removed_email_a[email protected]
wrote:

if click on {Send Button} appear an Rails error page


NoMethodError in FormonlineController#create

undefined method `deep_merge!’ for nil:NilClass

24. session[:formonline_params].deep_merge!(params[:formonline]) if
params[:formonline]

This is telling you that session[:formonline_params] has been nulled
out. Try detecting that condition and, if so, setting it to empty (or
some other sensible value), before this line. That will at least
bypass this crash, though I don’t know if it will let the back-button
work as you desire.

-Dave


Dave A.: Available Cleared Ruby on Rails Freelancer
(NoVa/DC/Remote) – see www.DaveAronson.com, and blogs at
www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs