From 86b2d25f212e668b47b62ec28aea2afe4476568e Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 15 Sep 2022 03:21:19 -0500 Subject: [PATCH] views: fix search forms to retain limit param. Fix search forms to retain the `limit` URL param if it was manually given in the URL. --- app/helpers/application_helper.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 8b490a17c..423376eea 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -253,7 +253,12 @@ module ApplicationHelper defaults = { required: false } html_options = { autocomplete: "off", class: "search-form #{classes}" } - simple_form_for(:search, method: method, url: url, defaults: defaults, html: html_options, &block) + simple_form_for(:search, method: method, url: url, defaults: defaults, html: html_options) do |f| + out = "".html_safe + out += tag.input(type: :hidden, name: :limit, value: params[:limit]) if params[:limit].present? + out += capture { yield f } if block_given? + out + end end def edit_form_for(model, **options, &block)