loop fixed for gallery widget

This commit is contained in:
Harry Bomrah 2014-06-17 16:39:39 +08:00
parent 6624156d57
commit 52278526e8
1 changed files with 6 additions and 2 deletions

View File

@ -36,9 +36,13 @@ class GalleriesController < ApplicationController
params = OrbitHelper.params
images = []
total_images = 0
if !albums.blank?
while images.count < 9 and images.count < AlbumImage.count
albums.each do |album|
total_images = total_images + album.album_images.count
end
total_images = total_images > 9 ? 9 : total_images
while images.count < total_images and images.count < AlbumImage.count
albums.each do |album|
img = album.album_images.sample
if !images.include?(img) && img != nil