html.erb conditionally add class code example Example: html.erb conditionally add class <div class="<%= @error ? 'error-class' : 'normal-class' %>">