Today I Learned

A Hashrocket project

Ready to join Hashrocket? Find Openings here and apply today.

Current Page Helper in Rails

It’s a common problem needing to know what page you’re currently on to perform some action.

Rails has a view helper: current_page? to help with this.

# do something special on root page
<% if current_page?(root_path) %>
    # HAPPY DANCE
<% end %>
Looking for help? Hashrocket has been an industry leader in Ruby on Rails since 2008. Rails is a core skill for each developer at Hashrocket, and we'd love to take a look at your project. Contact us and find out how we can help you.