diff options
| author | hukl <contact@smyck.org> | 2009-09-04 22:34:55 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-09-04 22:34:55 +0200 |
| commit | 96a928cdfd6854a168d6328bcf29096403e556db (patch) | |
| tree | 4ccdabb8f5186d355bf395772addfbd6afabc8ef /app/controllers | |
| parent | fed65d37b7894d7cccbe44757148c5441af90cc3 (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.rb | 8 |
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 |
