From 6ec8f6a5c0da663151cb1717151267c2d9527e77 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 4 Jun 2014 16:21:15 +0800 Subject: [PATCH] fixed infinite loop problem and also changed some engine settings --- app/controllers/galleries_controller.rb | 13 ++++++++----- lib/gallery/engine.rb | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/controllers/galleries_controller.rb b/app/controllers/galleries_controller.rb index e609f0a..a2d8810 100644 --- a/app/controllers/galleries_controller.rb +++ b/app/controllers/galleries_controller.rb @@ -34,11 +34,14 @@ class GalleriesController < ApplicationController params = OrbitHelper.params images = [] - while images.count < 9 and images.count < AlbumImage.count - albums.each do |album| - img = album.album_images.sample - if !images.include?(img) && img != nil - images << img + + if !albums.blank? + while images.count < 9 and images.count < AlbumImage.count + albums.each do |album| + img = album.album_images.sample + if !images.include?(img) && img != nil + images << img + end end end end diff --git a/lib/gallery/engine.rb b/lib/gallery/engine.rb index 3b668cb..13e34e9 100644 --- a/lib/gallery/engine.rb +++ b/lib/gallery/engine.rb @@ -5,7 +5,7 @@ module Gallery module_label "gallery.gallery" base_url File.expand_path File.dirname(__FILE__) widget_methods ["widget"] - widget_settings [{"data_count"=>10}] + widget_settings [] categorizable authorizable frontend_enabled