From 47f23a0cdd35725e48105597cb9ce1150f35fa06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Tue, 20 Apr 2021 16:22:56 +0800 Subject: [PATCH] add more one stage for domain --- app/controllers/ruling_templates_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/ruling_templates_controller.rb b/app/controllers/ruling_templates_controller.rb index 9f410e5..6d2446d 100644 --- a/app/controllers/ruling_templates_controller.rb +++ b/app/controllers/ruling_templates_controller.rb @@ -3,7 +3,8 @@ class RulingTemplatesController < ApplicationController store_token = params[:store_token] 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| + root_domain2 = root_domain.sub(/(?:(?!\.).)*\./,'') rescue '' + templates = RTemplate.where(:allow_domain.in => [site_domain,root_domain,root_domain2,'',nil]).asc(:updated_at).collect do |v| { 'install_flag' => v.installed_site_tokens.include?(store_token), 'uid' => v.uid, @@ -19,7 +20,8 @@ class RulingTemplatesController < ApplicationController store_token = params[:store_token] 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 + root_domain2 = root_domain.sub(/(?:(?!\.).)*\./,'') rescue '' + r_template = RTemplate.where(:allow_domain.in => [site_domain,root_domain,root_domain2,'',nil], uid: template_uid).first if r_template.nil? render :json => {}.to_json else