Hi, I'm Chris. I'm the creator of GoRails, Hatchbox.io and Jumpstart. I spend my time creating tutorials and tools to help Ruby on Rails developers build apps better and faster.
About This Episode
Learn how to link to the current page and add, remove, or modify params in the URL. This is handy for things like search or index pages with filters.
For additional security, you should whitelist the params that you want to allow in the links.
# app/helpers/search_helper.rb module SearchHelper def current_page_params # Modify this list to whitelist url params for linking to the current page request.params.slice("query", "filter", "sort") end end
<%= link_to "with foo", current_page_params.merge(foo: true) %> ```erb