changed the tag saving method
This commit is contained in:
parent
b6bb20d66a
commit
1769924137
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue