changed the tag saving method
This commit is contained in:
parent
b6bb20d66a
commit
1769924137
|
@ -184,11 +184,11 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@album = Album.find(params[:id])
|
album = Album.find(params[:id])
|
||||||
tagsToDestroy = []
|
tagsToDestroy = []
|
||||||
tagsToAdd = []
|
tagsToAdd = []
|
||||||
new_tags = params[:album][:tags] || []
|
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|
|
old_tags.each do |tag|
|
||||||
if !new_tags.include?(tag)
|
if !new_tags.include?(tag)
|
||||||
tagsToDestroy << tag
|
tagsToDestroy << tag
|
||||||
|
@ -201,16 +201,16 @@ class Admin::GalleriesController < OrbitAdminController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
update_children_image_tag(tagsToDestroy,tagsToAdd)
|
update_children_image_tag(album,tagsToDestroy,tagsToAdd)
|
||||||
@album.update_attributes(album_params)
|
album.update_attributes(album_params)
|
||||||
redirect_to "/admin/galleries/"+@album.id.to_s
|
redirect_to "/admin/galleries/"+album.id.to_s
|
||||||
end
|
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
|
# 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
|
# tagsToAdd will contain all tag ids which ve to be added in tall album_images
|
||||||
@images = AlbumImage.all
|
images = album.album_images
|
||||||
@images.each do |image|
|
images.each do |image|
|
||||||
image_tags = image.tags.collect{|t| t.id.to_s}
|
image_tags = image.tags.collect{|t| t.id.to_s}
|
||||||
tagsToAdd.each do |tag|
|
tagsToAdd.each do |tag|
|
||||||
image_tags << tag
|
image_tags << tag
|
||||||
|
|
Loading…
Reference in New Issue