From cae5b4accca2f880bbd4a5ffae265f78c689075c Mon Sep 17 00:00:00 2001 From: hukl Date: Tue, 1 Sep 2009 23:13:45 +0200 Subject: Added javascript goodness to add and sort and drag and drop images on pages --- app/controllers/pages_controller.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/controllers/pages_controller.rb') diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index e298265..4b3b541 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -12,4 +12,18 @@ class PagesController < ApplicationController end end + + + 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 + + render :nothing => true, :status => 200 + end end -- cgit v1.3