I know this is super basic, but I need some help.
In my view, which displays a form, if a field is nil or if there are
errors when the form is submitted, display "A", otherwise, display "B".
I can't figure out how to test for condition 1 OR 2. Instead the code
always executes "A".
Sample code looks like this:
<% if model.field.nil? or model.errors %>
You'll always get at least an empty array from model.errors
<% if model.field.nil? || model.errors.size > 0
<%= A %>
<% else %>
<%= B %>
<% end %>
I also tend to use || rather than or in this type of expression so the ultra-low precedence of 'or' doesn't cause seemingly odd behavior at times. (Of course, I worked in C for many years so || just seems natural.)