fix error

This commit is contained in:
邱博亞 2023-05-04 21:06:02 +08:00
parent 6a877c8e2d
commit ebdd9b6db4
2 changed files with 9 additions and 1 deletions

View File

@ -49,7 +49,7 @@ class GalleriesController < ApplicationController
thumb_src = a.cover_path(@image_version) thumb_src = a.cover_path(@image_version)
if thumb_src if thumb_src
thumb_srcs = thumb_src.split('/') thumb_srcs = thumb_src.split('/')
thumb_srcs[-1] = thumb_srcs[-1].sub(/^\w+_/,"") thumb_srcs[-1] = thumb_srcs[-1].sub(/^(?:(?!_).)*_/,"")
thumb_path = thumb_srcs[0..-2].join('/') thumb_path = thumb_srcs[0..-2].join('/')
thumb_path_name = thumb_srcs[-1] thumb_path_name = thumb_srcs[-1]
src = "#{thumb_path}/#{thumb_path_name}" src = "#{thumb_path}/#{thumb_path_name}"

View File

@ -37,6 +37,14 @@ class AlbumImage
Album.where(:id=>self.album_id).update_all(:min_order=>min_order + 1) Album.where(:id=>self.album_id).update_all(:min_order=>min_order + 1)
end end
end end
before_save do
if self.file_changed?
cover = self.album['cover']
if cover && cover == self.id
self.album.update_attributes({:cover_path => self.file.thumb.url, :cover=> self.id})
end
end
end
def title_translations def title_translations
tmp = super || {} tmp = super || {}
if tmp == {} if tmp == {}