Add an 'active' class to all active links in rails?

后端 未结 7 596
醉酒成梦
醉酒成梦 2021-02-05 15:08

Basically, I have a lot of code that looks like this:

link_to t(\'.profile\'), business_path(@business), class: \'#{\'active\' if current_page? business_path(@bu         


        
7条回答
  •  你的背包
    2021-02-05 15:58

    It's a solved problem, just use active_link_to gem. Your example simplifies to this:

    = active_link_to t('.profile'), business_path(@business)
    

提交回复
热议问题