diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 1d06cba..bdafa4b 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -35,7 +35,10 @@ class GalleriesController < ApplicationController end def index - albums = Album.filter_by_categories.filter_by_tags.asc(:order) + album_tp = Album.filter_by_categories.filter_by_tags + albums_no_order = album_tp.desc(:created_at).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) galleries = albums.collect do |a| doc = Nokogiri::HTML(a.description.to_s) alt_text = doc.text.empty? ? 'gallery image' : doc.text @@ -50,7 +53,7 @@ class GalleriesController < ApplicationController { "albums" => galleries, "extras" => {"widget-title"=>"Gallery"}, - "total_pages" => albums.total_pages + "total_pages" => album_tp.total_pages } end def show