I'm using Rails 4 and Chrome. The following results in the situation:
- Post a form that causes a validation error (ie. "Name cannot be empty")
- Post that same form successfully by correcting the input
- Hit the browser back button and the validation error from step 1 is shown on the input field even though it has a value that is not empty
Why does the validation error from the step 1 pop back and how to fix this behaviour? Note: Turbolinks is in use, could that be the reason?
Here's the way to replicate:
rails g scaffold Page name:string
class Page < ActiveRecord::Base
validates :name, presence: true
end
Navigate to /pages/new Submit (errors appear on the form) Fillout the name Submit again (redirected to successfully created model) Hit the browser back button (the validation errors are there, and the field is filled with the last supplied value)