Reputation: 5
I have a problem while making a back button for form in rails. I have a dynamic form that looks like this: dynamic form
However, when I press 'preview' button, the page will redirect to another page. In this page, I have created button:
<%= button_to 'Back to edit', 'javascript:history.go(-1);', {class:'btn btn-primary'} %>
It really back to previous form, but only 1 single form displayed returned form
Can anyone can help me???
Upvotes: 0
Views: 1899
Reputation: 2973
You can do this follow as:
<%= link_to 'Back to edit', :back %>
Upvotes: 2
Reputation: 11235
Most browsers will cache the back action and therefore won't issue an HTTP request to your server. If you need to display fresh data, then use a redirect via javascript's window.location
rather than relying on the history state.
Upvotes: 0