【问题标题】:Override 'field_with_errors' on a per view basis在每个视图的基础上覆盖“field_with_errors”
【发布时间】:2013-04-21 05:13:41
【问题描述】:

我知道您可以通过此问题中发布的方法覆盖 ActionView::Base:

Rails 3: "field-with-errors" wrapper changes the page appearance. How to avoid this?

但是,我想知道如何在每个视图的基础上禁用它?换句话说,除了我指定的视图之外,我希望在站点范围内使用默认行为。

【问题讨论】:

    标签: ruby-on-rails ruby-on-rails-3 actionview


    【解决方案1】:

    您可以在视图本身中执行此操作

    <% unless @user.errors["email"].blank? &>
         @user.errors["email"] = "your custom message"
     <% end %>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 2019-06-03
      • 1970-01-01
      • 2012-06-27
      • 2022-10-23
      • 2013-12-12
      相关资源
      最近更新 更多