From 6c9cb2b23d777541ab7a8d3fcb57c065f25851d2 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Fri, 4 Aug 2023 09:18:49 +0800 Subject: [PATCH] Fix bug. --- app/controllers/asia_databases_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/asia_databases_controller.rb b/app/controllers/asia_databases_controller.rb index f367dfb..acd6ed1 100644 --- a/app/controllers/asia_databases_controller.rb +++ b/app/controllers/asia_databases_controller.rb @@ -126,7 +126,9 @@ class AsiaDatabasesController < ApplicationController asia_data = asia_data.page(params[:page_no]).per(OrbitHelper.page_data_count) end asia_data_list = [] - if !params['keywords'].nil? + if params['keywords'].nil? + asia_data = nil + else if for_frontend asia_data_list = asia_data.collect do |asia_record| {'jps' => fields_to_show.map{|field| {"value"=> get_display_field(asia_record,field)}}} @@ -178,7 +180,7 @@ class AsiaDatabasesController < ApplicationController "asia_databases" => asia_data_list, "headers" => table_headers, "extras" => extras, - "total_pages" => asia_data.total_pages, + "total_pages" => (asia_data ? asia_data.total_pages : 0), 'choice_unit' => choice_unit, 'choice_field' => choice_field }