ruby-on-rails – Rails通过div包含错误的字段

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Rails通过div包含错误的字段前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何在未通过验证时停止Rails更改我的代码.

每次铁路包裹我的田地

  1. <div class='field_with_error'>...</div>

我可以编辑fields_with_error类

  1. .fields_with_error{ display: inline }

这是有效的,但它是hacky

解决方法

没关系.使用CSS而不是这样做.
  1. ActionView::Base.field_error_proc = Proc.new do |html_tag,instance_tag|
  2. "<span class='field_error'>#{html_tag}</span>"
  3. end

我觉得哪个更hacky

猜你在找的Ruby相关文章