Using Ruby and HAML, is there a shorter way to represent this logic:
%tr{class: "#{'success' if admin.approved?} #{'warning' unless admin.approved?}"}
Thanks!
You can simplify the logic using a ternary statement (one line if/else):
%tr{class: admin.approved? ? 'success' : 'warning'}
Or you could move the logic to a helper.  For example, create a helper method in application_helper.rb:
def admin_row_class(admin)
  admin.approved? ? 'success' : 'warning'
end
Then use the helper in your view:
%tr{class: admin_row_class(admin)}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With