From 1769924137502b948f435933b9dbeb8d46ec8215 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 2 Mar 2016 12:31:47 +0800 Subject: [PATCH] changed the tag saving method --- app/controllers/admin/galleries_controller.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/admin/galleries_controller.rb b/app/controllers/admin/galleries_controller.rb index a77a1af..0587076 100644 --- a/app/controllers/admin/galleries_controller.rb +++ b/app/controllers/admin/galleries_controller.rb @@ -184,11 +184,11 @@ class Admin::GalleriesController < OrbitAdminController end def update - @album = Album.find(params[:id]) + album = Album.find(params[:id]) tagsToDestroy = [] tagsToAdd = [] new_tags = params[:album][:tags] || [] - old_tags = @album.tags.collect{|t| t.id.to_s} + old_tags = album.tags.collect{|t| t.id.to_s} old_tags.each do |tag| if !new_tags.include?(tag) tagsToDestroy << tag @@ -201,16 +201,16 @@ class Admin::GalleriesController < OrbitAdminController end end end - update_children_image_tag(tagsToDestroy,tagsToAdd) - @album.update_attributes(album_params) - redirect_to "/admin/galleries/"+@album.id.to_s + update_children_image_tag(album,tagsToDestroy,tagsToAdd) + album.update_attributes(album_params) + redirect_to "/admin/galleries/"+album.id.to_s end - def update_children_image_tag(tagsToDestroy,tagsToAdd) + def update_children_image_tag(album,tagsToDestroy,tagsToAdd) # tagsToDestroy will contain all tag ids which have to be deleted from the galley_images # tagsToAdd will contain all tag ids which ve to be added in tall album_images - @images = AlbumImage.all - @images.each do |image| + images = album.album_images + images.each do |image| image_tags = image.tags.collect{|t| t.id.to_s} tagsToAdd.each do |tag| image_tags << tag