I am attempting to increment a value stored in params[:id] when an input botton is selected and store the original value when the user accessed the page. How do I approach accomplishing this?
I have successfully incremented the value but I am unsure of how to accomplish storing the original value?
There are several ways you could hang on to the value of “start” between requests. You could, as Matzi suggests, persist the value in the url as part of the query string between requests.
You could also stick the value in the user’s session from the controller:
Then retrieve it with
session[:start].You can also shove it in your own special cookie from the controller:
Or you could save the
params[:start]to the database if it was really important for that bit of data to persist.Hope that helps point you in the right direction.