Use class_names to Conditionally Apply CSS Classes

When you’re building views in Rails, you often need to apply CSS classes conditionally. Maybe a nav link should look different when it’s the current page, or a form field needs error styling. Since Rails 6.1, the class_names helper does this cleanly. Instead of… …interpolating conditional classes with ternaries or post-statement conditionals: <div class= "p-4 rounded <%= @error ? 'bg-red-50…