From c98ceae1d65dfb93ca0f5b8c007c7c183c8a7ea1 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 25 May 2015 21:45:08 +0800 Subject: [PATCH] fix for widget --- app/controllers/galleries_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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