fix for widget

This commit is contained in:
Harry Bomrah 2015-05-25 21:45:08 +08:00
parent 6da1ceb13f
commit c98ceae1d6
1 changed files with 4 additions and 2 deletions

View File

@ -44,8 +44,10 @@ class GalleriesController < ApplicationController
albums.each do |album| albums.each do |album|
total_images = total_images + album.album_images.count total_images = total_images + album.album_images.count
end end
counts = counts > total_images ? counts : total_images counts = counts > total_images ? total_images : counts
while images.count < counts and images.count < AlbumImage.count abc = AlbumImage.count
counts = counts > abc ? abc : counts
while images.count < counts
albums.each do |album| albums.each do |album|
img = album.album_images.sample img = album.album_images.sample
if !images.include?(img) && img != nil if !images.include?(img) && img != nil