Fix widget when album images less then 9 and fix update method redirect path

This commit is contained in:
manson 2014-05-26 10:08:14 +08:00
parent db67704a88
commit 60c4901070
2 changed files with 3 additions and 3 deletions

View File

@ -192,7 +192,7 @@ class Admin::GalleriesController < OrbitAdminController
end end
update_children_image_tag(tagsToDestroy,tagsToAdd) update_children_image_tag(tagsToDestroy,tagsToAdd)
@album.update_attributes(album_params) @album.update_attributes(album_params)
redirect_to admin_gallery_path(@album) redirect_to "/admin/galleries/"+@album.id.to_s
end end
def update_children_image_tag(tagsToDestroy,tagsToAdd) def update_children_image_tag(tagsToDestroy,tagsToAdd)

View File

@ -32,9 +32,9 @@ class GalleriesController < ApplicationController
def widget def widget
albums = Album.filter_by_widget_categories albums = Album.filter_by_widget_categories
params = OrbitHelper.params params = OrbitHelper.params
images = [] images = []
while images.count < 9 while images.count < 9 and images.count < AlbumImage.count
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