Suppose you want to add a class to the following class only when there are "certain conditions".
<div class="container">
</div>
For example, suppose this time we add a class only when ʻusers_controller`. The conditional expression in that case is as follows.
<div class="container<%= ' user-container' if controller_name = 'users' %>">
</div>
Leave a space before the first letter of the class name you want to add.
correct:<%= ' user-container'if ...
mistake:<%= 'user-container'if ...
By adding class
with such a condition, you can change or overwrite the style with CSS only under that condition, so please remember.
Recommended Posts