I got a form like this
<%= form_for @checkout_form, url: checkout_path(@checkout_form), html: {class: 'details-form', method: :put} do |f| %>
<%= f.fields_for :billing_address do |builder| %>
<% error_class = @checkout_form.billing_address.errors[:phone].any? ? 'error' : '' %>
<%= builder.text_field :phone, class: "text #{error_class}" %>
<% end %>
<% end %>
Everything is working fine except for the error class. I'm not really sure how I can grab the errors for that specific field in that context.
If I try it like this I get
undefined method `errors' for nil:NilClass