From 96a928cdfd6854a168d6328bcf29096403e556db Mon Sep 17 00:00:00 2001 From: hukl Date: Fri, 4 Sep 2009 22:34:55 +0200 Subject: moved the image sorting into the model and wrapped it into a transaction --- app/controllers/pages_controller.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'app/controllers/pages_controller.rb') diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 4b3b541..6e826c0 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -16,13 +16,7 @@ class PagesController < ApplicationController def sort_images page = Page.find(params[:id]) - - page.related_assets.destroy_all - - params[:images].each_with_index do |id, index| - asset = Asset.find(id) - page.related_assets.create(:asset_id => asset.id, :position => index+1) - end + page.update_assets(params[:images]) render :nothing => true, :status => 200 end -- cgit v1.3