diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 69cb06d45..77afc1317 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -14,4 +14,10 @@ module ApplicationHelper
home_page? ? '' : 'results'
end
+ # if current path is /debates current_path_with_query_params(foo: 'bar') returns /debates?foo=bar
+ # notice: if query_params have a param which also exist in current path, it "overrides" (query_params is merged last)
+ def current_path_with_query_params(query_parameters)
+ url_for(request.query_parameters.merge(query_parameters))
+ end
+
end
diff --git a/app/views/admin/comments/index.html.erb b/app/views/admin/comments/index.html.erb
index 941e1e9ed..87178c66b 100644
--- a/app/views/admin/comments/index.html.erb
+++ b/app/views/admin/comments/index.html.erb
@@ -8,7 +8,7 @@
<%= t("admin.comments.index.filters.#{filter}") %>
<% else %>
<%= link_to t("admin.comments.index.filters.#{filter}"),
- admin_comments_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/admin/debates/index.html.erb b/app/views/admin/debates/index.html.erb
index cdeb7b016..9ac89b5e1 100644
--- a/app/views/admin/debates/index.html.erb
+++ b/app/views/admin/debates/index.html.erb
@@ -8,7 +8,7 @@
<%= t("admin.debates.index.filters.#{filter}") %>
<% else %>
<%= link_to t("admin.debates.index.filters.#{filter}"),
- admin_debates_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/admin/organizations/index.html.erb b/app/views/admin/organizations/index.html.erb
index df003e6f8..8569d0c47 100644
--- a/app/views/admin/organizations/index.html.erb
+++ b/app/views/admin/organizations/index.html.erb
@@ -21,7 +21,7 @@
<%= t("admin.organizations.index.filters.#{filter}") %>
<% else %>
<%= link_to t("admin.organizations.index.filters.#{filter}"),
- admin_organizations_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/admin/users/index.html.erb b/app/views/admin/users/index.html.erb
index 8f728295d..b6f3f1cfe 100644
--- a/app/views/admin/users/index.html.erb
+++ b/app/views/admin/users/index.html.erb
@@ -8,7 +8,7 @@
<%= t("admin.users.index.filters.#{filter}") %>
<% else %>
<%= link_to t("admin.users.index.filters.#{filter}"),
- admin_users_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/debates/index.html.erb b/app/views/debates/index.html.erb
index 71266aeb2..701110af3 100644
--- a/app/views/debates/index.html.erb
+++ b/app/views/debates/index.html.erb
@@ -16,7 +16,7 @@
<%= t("debates.index.all") %>
<% @tags.each do |tag| %>
-
+
<%= tag.name %>
<% end %>
@@ -31,7 +31,7 @@
<% @valid_orders.each do |order| %>
- value='<%= url_for(request.query_parameters.merge(order: order))%>'>
+ value='<%= current_path_with_query_params(order: order) %>'>
<%= t("debates.index.orders.#{order}") %>
<% end %>
diff --git a/app/views/moderation/comments/index.html.erb b/app/views/moderation/comments/index.html.erb
index f9c95e9be..da2bb8251 100644
--- a/app/views/moderation/comments/index.html.erb
+++ b/app/views/moderation/comments/index.html.erb
@@ -8,7 +8,7 @@
<%= t("moderation.comments.index.filters.#{filter}") %>
<% else %>
<%= link_to t("moderation.comments.index.filters.#{filter}"),
- moderation_comments_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/moderation/debates/index.html.erb b/app/views/moderation/debates/index.html.erb
index cbd6baa5d..8fb013605 100644
--- a/app/views/moderation/debates/index.html.erb
+++ b/app/views/moderation/debates/index.html.erb
@@ -8,7 +8,7 @@
<%= t("moderation.debates.index.filters.#{filter}") %>
<% else %>
<%= link_to t("moderation.debates.index.filters.#{filter}"),
- moderation_debates_path(filter: filter) %>
+ current_path_with_query_params(filter: filter) %>
<% end %>
<% end %>
diff --git a/app/views/shared/_locale_switcher.html.erb b/app/views/shared/_locale_switcher.html.erb
index f76a71b9c..763acc4b9 100644
--- a/app/views/shared/_locale_switcher.html.erb
+++ b/app/views/shared/_locale_switcher.html.erb
@@ -4,7 +4,7 @@
<% I18n.available_locales.map do |loc| %>
- value='<%= url_for(request.query_parameters.merge(locale: loc))%>'>
+ value='<%= current_path_with_query_params(locale: loc) %>'>
<%= I18n.t('locale', locale: loc) %>
<% end %>