Just to help other developers, because there is no similar question on SO.
div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)
See the examples below:
div class=(is_active? ? 'active' : 'inactive')
div class=('active' if is_active?)
The same approach can be used to assign dynamic values to other attributes.