From 5314f282e1b23b77c44bd1e0918989ab85dba10d Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 5 Mar 2020 18:36:28 +0800 Subject: [PATCH] fix error for multiple locale on --- app/controllers/announcements_controller.rb | 4 ++-- app/models/anns_cache.rb | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index d6355c5..e81c146 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -113,7 +113,7 @@ class AnnouncementsController < ApplicationController tags = OrbitHelper.widget_tags || [] cats = OrbitHelper.widget_categories || [] subpart = OrbitHelper.get_current_widget - anns_cache = AnnsCache.where(parent_id: subpart.id) + anns_cache = AnnsCache.where(parent_id: subpart.id,locale: I18n.locale.to_s) widget_data_count = OrbitHelper.widget_data_count if !(defined? SiteFeed).nil? || anns_cache.count != 1 || is_random page = Page.where(:module => "announcement").first rescue nil @@ -128,7 +128,7 @@ class AnnouncementsController < ApplicationController if anns_cache.count > 1 anns_cache.destroy end - AnnsCache.create(parent_id: subpart.id,filter_result: sorted_anns.map{|v| v.id}) + AnnsCache.create(parent_id: subpart.id,locale: I18n.locale.to_s,filter_result: sorted_anns.map{|v| v.id}) else sorted_anns = sorted_anns.sample(widget_data_count) end diff --git a/app/models/anns_cache.rb b/app/models/anns_cache.rb index 444b620..881ca02 100644 --- a/app/models/anns_cache.rb +++ b/app/models/anns_cache.rb @@ -2,6 +2,5 @@ class AnnsCache include Mongoid::Document field :parent_id field :filter_result,type: Array,default: [] - field :tag_ids,type: Array,default: [] - field :cat_ids,type: Array,default: [] + field :locale,type: String,default: 'zh_tw' end \ No newline at end of file