Forum: Ruby on Rails no-cache issue Safari and Mozilla Firefox

Ade19030f462462be502b3c76124fce0?d=identicon&s=25 Cluter Vipic (cluter)
on 2012-02-17 03:35
Hi Folks,

I'm writing a multistep form with the the help of Ryan Bates

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-b...

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"=>"postmasetr@myappname.com"},
 "commit"=>"Continue"}
************************************************

on the 24 raw of form online

*************************************************
22. def create

  24. session[:formonline_params].deep_merge!(params[:formonline]) if
params[:formonline]
  25. @formonline = Formonline.new(session[:formonline_params])
  26. @formonline.current_step = session[:formonline_step]
  27. if @formonline.valid?
  28  if params[:back_button]
  29  ........

35. ..........
*************************************************

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"=>"postmasetr@myappname.com"},
 "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
Ec2c1a36301b0223c3e281bd2ec3f37a?d=identicon&s=25 Dave Aronson (Guest)
on 2012-02-17 17:58
(Received via mailing list)
On Thu, Feb 16, 2012 at 21:35, Cluter Vipic <lists@ruby-forum.com>
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 Aronson: 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
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.