fix error

This commit is contained in:
chiu 2020-09-08 17:25:37 +08:00
parent 9654db689a
commit 768f2ffe05
2 changed files with 6 additions and 6 deletions

View File

@ -274,7 +274,7 @@ class Admin::GalleriesController < OrbitAdminController
categories = @module_app.categories.enabled categories = @module_app.categories.enabled
@filter_fields = filter_fields(categories, @tags) @filter_fields = filter_fields(categories, @tags)
@filter_fields.delete(:status) @filter_fields.delete(:status)
albums1 = Album.where(:order => -1).desc(:created_at).with_categories(filters("category")).with_tags(filters("tag")) albums1 = Album.where(:order.in => [nil,-1]).desc(:created_at).with_categories(filters("category")).with_tags(filters("tag"))
albums1 = search_data(albums1,[:name]) albums1 = search_data(albums1,[:name])
albums2 = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag")) albums2 = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag"))
albums2 = search_data(albums2,[:name]) albums2 = search_data(albums2,[:name])
@ -331,7 +331,7 @@ class Admin::GalleriesController < OrbitAdminController
def show def show
@album = Album.find(params[:id]) @album = Album.find(params[:id])
@images = @album.album_images.where(:order => -1).desc(:created_at) @images = @album.album_images.where(:order => [nil,-1]).desc(:created_at)
images = @album.album_images.where(:order.gt => -1).asc(:order) images = @album.album_images.where(:order.gt => -1).asc(:order)
@images = @images.concat(images) @images = @images.concat(images)
image_content = [] image_content = []
@ -414,7 +414,7 @@ class Admin::GalleriesController < OrbitAdminController
def get_photoData_json def get_photoData_json
@album = Album.find(params[:id]) @album = Album.find(params[:id])
@images = @album.album_images.where(:order => -1).desc(:created_at) @images = @album.album_images.where(:order => [nil,-1]).desc(:created_at)
images = @album.album_images.where(:order.gt => -1).asc(:order) images = @album.album_images.where(:order.gt => -1).asc(:order)
@images = @images.concat(images) @images = @images.concat(images)
image_content = [] image_content = []
@ -582,7 +582,7 @@ class Admin::GalleriesController < OrbitAdminController
lastimage = AlbumImage.find(params[:last_image_id]) lastimage = AlbumImage.find(params[:last_image_id])
@newimages = @album.album_images.where(:created_at.gt => lastimage.created_at,:order => -1).desc(:created_at) @newimages = @album.album_images.where(:created_at.gt => lastimage.created_at,:order => -1).desc(:created_at)
else else
@newimages = @album.album_images.where(:order => -1).desc(:created_at) @newimages = @album.album_images.where(:order => [nil,-1]).desc(:created_at)
end end
render :layout=>false render :layout=>false
end end

View File

@ -36,7 +36,7 @@ class GalleriesController < ApplicationController
def index def index
album_tp = Album.filter_by_categories.filter_by_tags album_tp = Album.filter_by_categories.filter_by_tags
albums_no_order = album_tp.desc(:created_at).select{|v| v.order == -1} albums_no_order = album_tp.desc(:created_at).select{|v| v.order == -1 || v.order == nil}
albums_with_order = album_tp.asc(:order).select{|v| v.order != -1} albums_with_order = album_tp.asc(:order).select{|v| v.order != -1}
albums = albums_no_order.concat(albums_with_order) albums = albums_no_order.concat(albums_with_order)
galleries = albums.collect do |a| galleries = albums.collect do |a|