summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-09-04 22:34:55 +0200
committerhukl <contact@smyck.org>2009-09-04 22:34:55 +0200
commit96a928cdfd6854a168d6328bcf29096403e556db (patch)
tree4ccdabb8f5186d355bf395772addfbd6afabc8ef /app/controllers
parentfed65d37b7894d7cccbe44757148c5441af90cc3 (diff)
moved the image sorting into the model and wrapped it into a transaction
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/pages_controller.rb8
1 files changed, 1 insertions, 7 deletions
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
16 16
17 def sort_images 17 def sort_images
18 page = Page.find(params[:id]) 18 page = Page.find(params[:id])
19 19 page.update_assets(params[:images])
20 page.related_assets.destroy_all
21
22 params[:images].each_with_index do |id, index|
23 asset = Asset.find(id)
24 page.related_assets.create(:asset_id => asset.id, :position => index+1)
25 end
26 20
27 render :nothing => true, :status => 200 21 render :nothing => true, :status => 200
28 end 22 end