I have a rails 3 application where I am passing some string queries like this:
<%= link_to "All", work_orders_path(params.merge({:status_filter => "E", :sort_filter => params[:sort_filter]})) %>
Everything works persistence wise in my views for work_order which is what these parameters are intended for (sorting and filtering existing work orders.)
The problem that I’m having is that when I go to add a new work order with a link_to, or attempt a link_to to another controller, the :status_filter and :sort_filter both are persisting, causing a routing error.
For example when I want to hit the index to view all technicians (of which these are not applicable I get
No route matches {:sort_filter=>nil, :status_filter=>”E”,
:controller=>”technicians”}
I’ve looked everywhere for a solution but as of yet I’ve been unable to come up with anything. I’ve tried params.delete, no dice. I know there must be an easy way to clear these from the URL in the link_to but I can’t figure it out.
I figured out that these links for all my navigation are in my application.html.erb, so any params I use there are carried across the entire app. I still haven’t figured out why. I moved these links to the index.html.erb file in work_orders and now everything else works.