From 5cd65d997ff482e5e6dfb2d6c77f9b58be8293a1 Mon Sep 17 00:00:00 2001 From: Bohung Date: Mon, 12 Apr 2021 14:39:11 +0800 Subject: [PATCH] Fix bug. --- app/controllers/admin/ruling_templates_controller.rb | 6 +++++- app/controllers/ruling_templates_controller.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/ruling_templates_controller.rb b/app/controllers/admin/ruling_templates_controller.rb index 0300b6c..c48abe5 100644 --- a/app/controllers/admin/ruling_templates_controller.rb +++ b/app/controllers/admin/ruling_templates_controller.rb @@ -83,7 +83,11 @@ class Admin::RulingTemplatesController < OrbitAdminController FileUtils.remove_dir(directory) render :json => {"psd_id" => psd.id.to_s, "path" => psd.psd_zip.path}.to_json end - + def destroy + template = RTemplate.find(params[:id]) + template.destroy + redirect_to :back + end private def template_params diff --git a/app/controllers/ruling_templates_controller.rb b/app/controllers/ruling_templates_controller.rb index 674226a..c5b9026 100644 --- a/app/controllers/ruling_templates_controller.rb +++ b/app/controllers/ruling_templates_controller.rb @@ -2,7 +2,7 @@ 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: site_domain,:git_url.ne=> '').asc(:updated_at).collect do |v| + templates = RTemplate.where(:allow_domain.in => [site_domain,'',nil]).asc(:updated_at).collect do |v| { 'install_flag' => v.installed_site_tokens.include?(store_token), 'uid' => v.uid,