From 6da1ceb13f91cde489e198c9a34444a5a12a6301 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 25 May 2015 21:24:19 +0800 Subject: [PATCH] fix for infinite loop if less images --- app/controllers/galleries_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index 68b23e7..747e690 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -44,7 +44,7 @@ class GalleriesController < ApplicationController albums.each do |album| total_images = total_images + album.album_images.count end - total_images = counts > 9 ? 9 : counts + counts = counts > total_images ? counts : total_images while images.count < counts and images.count < AlbumImage.count albums.each do |album| img = album.album_images.sample