fix error

This commit is contained in:
chiu 2021-09-17 13:43:32 +08:00
parent eca64d50cc
commit 7568aaafaf
2 changed files with 7 additions and 2 deletions

View File

@ -6,7 +6,7 @@ class ArchiveCategory
if(!record.new_record? && record.sort_number.class != Fixnum) if(!record.new_record? && record.sort_number.class != Fixnum)
record.sort_number = 0 record.sort_number = 0
record.save record.save
elsif(!record.new_record?) elsif(!record.new_record?)
@category = Category.find(record.category_id) rescue nil @category = Category.find(record.category_id) rescue nil
if !@category.nil? if !@category.nil?
@sort_number = @category.sort_number rescue nil @sort_number = @category.sort_number rescue nil

View File

@ -15,7 +15,12 @@ class ArchiveFile
# BelongsToCategory = :archive_file_category # BelongsToCategory = :archive_file_category
# PAYMENT_TYPES = @site_valid_locales # PAYMENT_TYPES = @site_valid_locales
before_save do
cat = self.category rescue nil
if cat && ArchiveCategory.where(:category_id => cat.id).count==0
ArchiveCategory.create(category_id: cat.id.to_s)
end
end
field :title, as: :slug_title, localize: true field :title, as: :slug_title, localize: true
field :description, localize: true field :description, localize: true