From 824bf50bf69b10f6444d5701472bdd21630e034d Mon Sep 17 00:00:00 2001 From: rulingcom Date: Thu, 15 Oct 2026 18:29:33 +0800 Subject: [PATCH] Fix Rails 7 / Mongoid 8 compatibility and frontend issues --- .../admin/universal_tables_controller.rb | 4 ++-- app/controllers/universal_tables_controller.rb | 14 +++++++++----- app/helpers/admin/universal_tables_helper.rb | 4 ++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/universal_tables_controller.rb b/app/controllers/admin/universal_tables_controller.rb index 0dd0b5d..775f167 100755 --- a/app/controllers/admin/universal_tables_controller.rb +++ b/app/controllers/admin/universal_tables_controller.rb @@ -246,7 +246,7 @@ end elsif title_for_category["zh_tw"] == "" && title_for_category["en"] != "" title_for_category["zh_tw"] = title_for_category["en"] end - category.title_translations = title_for_category + category.title_translations = title_for_category.to_unsafe_h category.module_app = @module_app category.save p = table_params @@ -276,7 +276,7 @@ end elsif title_for_category["zh_tw"] == "" && title_for_category["en"] != "" title_for_category["zh_tw"] = title_for_category["en"] end - cat.title_translations = title_for_category + cat.title_translations = title_for_category.to_unsafe_h cat.save p[:category_id] = cat.id table.update_attributes(p) diff --git a/app/controllers/universal_tables_controller.rb b/app/controllers/universal_tables_controller.rb index 2c5dc0d..c78c437 100755 --- a/app/controllers/universal_tables_controller.rb +++ b/app/controllers/universal_tables_controller.rb @@ -120,10 +120,11 @@ class UniversalTablesController < ApplicationController end def get_query(params) - if params["column"].present? + if params["column"].present? && params["q"].is_a?(String) q = {params["column"] => params["q"]} else q = params["q"] + q = q.to_unsafe_h if q.respond_to?(:to_unsafe_h) end if q.present? q.map{|k,v| [k, v.to_s.strip] if v.present?}.compact.to_h @@ -401,6 +402,7 @@ class UniversalTablesController < ApplicationController rows = [] entries = get_entries(params, table, page) total_pages = entries.total_pages + show_hashtags = Hashtagging.where(:hashtaggable_id.in => TableEntry.where(:u_table_id => table.id).pluck(:id)).exists? table_heads << { "title" => t("universal_table.hashtags"), "type" => "hashtag", @@ -411,7 +413,7 @@ class UniversalTablesController < ApplicationController "sort-class" => "sort hide", "sort-url" => "", "title-class" => " no-search" - } + }if show_hashtags if have_serial_number page_no_offset = (params_no.present? ? [0, params_no.to_i - 1].max : 0) serial_number_count = page_no_offset * OrbitHelper.page_data_count @@ -455,9 +457,11 @@ class UniversalTablesController < ApplicationController cols << {"text" => ""} end end - text = te.hashtags_for_frontend - cols << {"text" => text} - rows << { + if show_hashtags + text = te.hashtags_for_frontend + cols << {"text" => text} + end + rows << { "columns" => cols } end diff --git a/app/helpers/admin/universal_tables_helper.rb b/app/helpers/admin/universal_tables_helper.rb index e7ddc66..f3d06eb 100755 --- a/app/helpers/admin/universal_tables_helper.rb +++ b/app/helpers/admin/universal_tables_helper.rb @@ -17,8 +17,8 @@ module Admin::UniversalTablesHelper end def render_unique_texts(f,column,i) - select_values = column.column_entries.distinct(:text) - select = "" s = {"en" => "", "zh_tw" => ""} select = select + "" select_values.each do |sv|