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

后端 未结 7 593
醉酒成梦
醉酒成梦 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:59

    This is a good case for writing your own helper that wraps the link_to. In your application_helper.rb you can write a method active_link_to that takes the same params as link_to + current_page, and then just calls link_to like you are doing above.

    0 讨论(0)
提交回复
热议问题