diff --git a/lib/kaminari/helpers/sinatra_helpers.rb b/lib/kaminari/helpers/sinatra_helpers.rb index a7a57e6..20171c2 100644 --- a/lib/kaminari/helpers/sinatra_helpers.rb +++ b/lib/kaminari/helpers/sinatra_helpers.rb @@ -89,7 +89,7 @@ def link_to_unless(condition, name, options = {}, html_options = {}, &block) # In that case, please add `template: self` option when calling this method. def paginate(scope, options = {}) current_path = env['PATH_INFO'] rescue nil - current_params = Rack::Utils.parse_query(env['QUERY_STRING']).symbolize_keys rescue {} + current_params = Rack::Utils.parse_query(env['QUERY_STRING']).map{|k, v| [k.delete("[]"), v]}.to_h.symbolize_keys rescue {} template = ActionViewTemplateProxy.new current_params: current_params, current_path: current_path, param_name: options[:param_name] || Kaminari.config.param_name diff --git a/test/helpers/sinatra_helpers_test.rb b/test/helpers/sinatra_helpers_test.rb index 43086b5..a331622 100644 --- a/test/helpers/sinatra_helpers_test.rb +++ b/test/helpers/sinatra_helpers_test.rb @@ -168,6 +168,12 @@ def last_document assert_match(/user_page=\d+/, elm.attribute('href').value) end end + + test 'Include nested query in query' do + get '/users', attribute: [:adult, :children] + + assert_match(/users\?attribute%5B%5D=adult&attribute%5B%5D=children/, last_document.search('a').attribute('href').value) + end end end