Rails 7 #136 Highlight link to current page

10/07/2023 (11 months ago)

Highlighting the link to the current page is a very common frontend navigation problem that needs to be solved in all sorts of Rails apps.

In this episode we will explore different approaches to highlighting link to current page, and write our own universal method for it.
We will also explore debugging and writing tests - crucial skills of a software developer!
Finally, feel free to use active_link_to in your app!

This can look like a very trivial problem to solve and to record, but in reality it took me more than 8 hours to research all the approaches, write a blogpost, write a script, and record this video.
I spend my time on finding perfect solutions so that You do not have to!

Episode source code: https://github.com/corsego/136-highlight-link-to-active/commit/da463fe627df9cd460063ba56183dca2d65b2faf
Based on this blogpost: https://blog.corsego.com/ruby-on-rails-highlight-linkto-current-page

0:00 Current solutions to highlighting link to current page
1:28 The problem with RailsDevs approach
5:30 active_link_to helper that works with blocks and inline
10:58 Write tests, otherwise I will not approve your Pull Request!
13:45 Final demo


1
Sign in to join the conversation