如果存在的形式(主要來自外部API)語義錯誤,我想添加的說明信息,像這樣:添加消息formtastic語義錯誤塊
<%= semantic_form_for @order, :url => checkout_purchase_url, :html => {:class => 'payment'}, :wrapper_html => { :class => "field" } do |f| %>
<% if f.has_errors? %>
<p>There were errors that prevented your order from being submitted. If you need assistance, please contact us toll-free at <strong>1-800-555-5555</strong>.</p>
<%= f.semantic_errors %>
<% end %>
<% end %>
然而,has_errors?
是一個受保護方法。有沒有辦法可以做到這一點?謝謝。