From 041fd786781bf36190b6b3e1d0fa56b03c8ad246 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 19 Apr 2021 09:42:09 +0800 Subject: [PATCH] fix error --- app/controllers/ruling_templates_controller.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/ruling_templates_controller.rb b/app/controllers/ruling_templates_controller.rb index c5b9026..9f410e5 100644 --- a/app/controllers/ruling_templates_controller.rb +++ b/app/controllers/ruling_templates_controller.rb @@ -1,8 +1,9 @@ class RulingTemplatesController < ApplicationController def index store_token = params[:store_token] - site_domain = RegisteredSite.find_by(:uid => store_token).site_domain.sub(/(?:(?!\.).)*\./,'') rescue '' - templates = RTemplate.where(:allow_domain.in => [site_domain,'',nil]).asc(:updated_at).collect do |v| + site_domain = RegisteredSite.find_by(:uid => store_token).site_domain + root_domain = site_domain.sub(/(?:(?!\.).)*\./,'') rescue '' + templates = RTemplate.where(:allow_domain.in => [site_domain,root_domain,'',nil]).asc(:updated_at).collect do |v| { 'install_flag' => v.installed_site_tokens.include?(store_token), 'uid' => v.uid, @@ -16,8 +17,9 @@ class RulingTemplatesController < ApplicationController def get_template_zip template_uid = params[:template_uid] store_token = params[:store_token] - site_domain = RegisteredSite.find_by(:uid => store_token).site_domain.sub(/(?:(?!\.).)*\./,'') rescue '' - r_template = RTemplate.where(allow_domain: site_domain, uid: template_uid).first + site_domain = RegisteredSite.find_by(:uid => store_token).site_domain + root_domain = site_domain.sub(/(?:(?!\.).)*\./,'') rescue '' + r_template = RTemplate.where(:allow_domain.in => [site_domain,root_domain,'',nil], uid: template_uid).first if r_template.nil? render :json => {}.to_json else