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

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -