http - Losing session and cookies after clicking on link -


In a Rail 4 multi-application application, I am trying to continue the form data in the session if the user Need to go back and edit the form before submitting it

Page 1 contains the form page 2, page 2 shows data to the user with the option of "go back" or "submit" form. Below is the code of the "Back" element:

  <% = link_to 'go back', {controller: partial, action :: index}, id: 'go_back_btn'% & gt; ;   

I also have my sessions and cookies displayed on each page for troubleshooting:

  <% = session [: formData]. Interview% & gt;   

problem

When I click the button described above ( & lt; a & gt; tag actually) I click on, I go back to page 1 but my session is zero I also had the value in the cookies, but they were also set as zero .

Why is this happening? How can I fix this?

It has been found that the session was being explicitly reset in the action of an administrator (with that Get rid of it) and cookies can not be set by this hash or session (such behavior can not be confirmed). So the solution was sent to paste the desired data into a JSON object as a session and to see them, where I used javascript to recoup the form using JSON.

In the Controller:

  DIF index # conditionally stores the previously prepared form data from the session in session if session [: myData] # session data to the frequency variable Store in and change it to JSON @ myData = session [: myData] .to_json # Reset session Optional Reset_assation End End   

In this view:

 < Code> & lt;% if @MyData% & gt; & Lt; Script type = "text / javascript" & gt; // Controller Example Variables need to call Store Value // Raw method, then Browser @MyDeta (Jason object) var myData = & lt;% = raw @ myData% & gt; Can not avoid the quotation marks present in it; // Some of my data with you & lt; / Script & gt; & Lt;% end% & gt;    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -