当验证未通过时,如何停止 Rails 更改我的代码。
每次 rails 用
包裹我的字段<div class='field_with_error'>...</div>
我可以编辑 fields_with_error
类
.fields_with_error{ display: inline }
这行得通,但它是 hacky
最佳答案
没关系。使用 CSS 而不是这样做。
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag| "<span class='field_error'>#{html_tag}</span>" end
我觉得这更 hacky :)
关于ruby-on-rails - Rails 通过 div 包装有错误的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5354854/