ruby on rails - Conditionally add class to link_to with slim syntax -
i have link , code follows:
= link_to 'payment', account_payment_path, class:{'active'}
and want add conditional logic view, if action_name
same, add class active
i change following code
= link_to 'payment', account_payment_path, class:{'active' if action_name == 'payment'}
but results in error. how can fix it.?
if want active links there gem build active_link_to, can use , handle adding active class you:
=active_link_to 'payment', account_payment_path
for problem can use this:
= link_to 'payment', account_payment_path, class: (action_name == 'payment' ? 'active' : '')
Comments
Post a Comment