【发布时间】:2014-09-09 14:40:32
【问题描述】:
我正在使用 Rails 4 和 Chrome。结果如下:
- 发布导致验证错误的表单(即“名称不能为空”)
- 通过更正输入成功发布相同的表单
- 点击浏览器后退按钮,步骤 1 中的验证错误会显示在输入字段中,即使它的值不为空
为什么会弹出第 1 步中的验证错误以及如何解决此问题?注意:Turbolinks 正在使用中,可能是这个原因吗?
复制方法如下:
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)
【问题讨论】:
标签: ruby-on-rails google-chrome form-submit back-button validationerror