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
@filter_fields = filter_fields(categories, @tags)
@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])
albums2 = Album.where(:order.gt => -1).asc(:order).with_categories(filters("category")).with_tags(filters("tag"))
albums2 = search_data(albums2,[:name])
@ -331,7 +331,7 @@ class Admin::GalleriesController < OrbitAdminController
def show
@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 = @images.concat(images)
image_content = []
@ -414,9 +414,9 @@ class Admin::GalleriesController < OrbitAdminController
def get_photoData_json
@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 = @images.concat(images)
@images = @images.concat(images)
image_content = []
@images.each do |image|
image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tags.collect{|t| t.id.to_s}}
@ -582,7 +582,7 @@ class Admin::GalleriesController < OrbitAdminController
lastimage = AlbumImage.find(params[:last_image_id])
@newimages = @album.album_images.where(:created_at.gt => lastimage.created_at,:order => -1).desc(:created_at)
else
@newimages = @album.album_images.where(:order => -1).desc(:created_at)
@newimages = @album.album_images.where(:order => [nil,-1]).desc(:created_at)
end
render :layout=>false
end

View File

@ -36,7 +36,7 @@ class GalleriesController < ApplicationController
def index
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 = albums_no_order.concat(albums_with_order)
galleries = albums.collect do |a|