fix bug for production mode

This commit is contained in:
邱博亞 2021-01-18 14:36:08 +08:00
parent b318ecf016
commit 3c57c25b45
2 changed files with 17 additions and 7 deletions

View File

@ -1,12 +1,5 @@
class ArchivesController < ApplicationController class ArchivesController < ApplicationController
#avoid the categories to be not in the ArchiveCategory #avoid the categories to be not in the ArchiveCategory
categories_temp = ModuleApp.where(:key => "archive").first.categories
categories_temp.each do |category|
archive_cat = ArchiveCategory.where(:category_id => category.id)
if archive_cat.count == 0
ArchiveCategory.create(category_id: category.id.to_s)
end
end
def serve_cmap def serve_cmap
serve_path=File.expand_path("../../assets/javascripts/archive/pdf/bcmaps/#{params[:file_name]}.#{params[:extension]}",__FILE__) serve_path=File.expand_path("../../assets/javascripts/archive/pdf/bcmaps/#{params[:file_name]}.#{params[:extension]}",__FILE__)
if Dir.glob(serve_path).length != 0 if Dir.glob(serve_path).length != 0

View File

@ -1,6 +1,23 @@
module Archive module Archive
class Engine < ::Rails::Engine class Engine < ::Rails::Engine
initializer "archive" do initializer "archive" do
require File.expand_path('../../../app/models/archive_category', __FILE__)
require "#{ENV['PWD']}/app/models/category"
require "#{ENV['PWD']}/app/models/module_app"
categories_temp = ModuleApp.where(:key => "archive").first.categories
categories_temp.each do |category|
archive_cat = ArchiveCategory.where(:category_id => category.id)
if archive_cat.count == 0
ArchiveCategory.create(category_id: category.id.to_s)
else
archive_cat[1..-1].each do |cat|
cat.delete
end
end
end
OrbitApp.registration "Archive", :type => "ModuleApp" do OrbitApp.registration "Archive", :type => "ModuleApp" do
module_label "archive.archive" module_label "archive.archive"
base_url File.expand_path File.dirname(__FILE__) base_url File.expand_path File.dirname(__FILE__)