diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 747e690..636bab6 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -44,8 +44,10 @@ class GalleriesController < ApplicationController albums.each do |album| total_images = total_images + album.album_images.count end - counts = counts > total_images ? counts : total_images - while images.count < counts and images.count < AlbumImage.count + counts = counts > total_images ? total_images : counts + abc = AlbumImage.count + counts = counts > abc ? abc : counts + while images.count < counts albums.each do |album| img = album.album_images.sample if !images.include?(img) && img != nil