summaryrefslogtreecommitdiff
path: root/app/controllers/menu_items_controller.rb
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-08-09 14:45:12 +0200
committerhukl <contact@smyck.org>2009-08-09 14:45:12 +0200
commit97aecb984afa6a7d8d1424f544b8e32d8c87603d (patch)
tree8939b12d327875241179c07ac975871cabdb582c /app/controllers/menu_items_controller.rb
parent72593784d6d580ea8cc6987a83cf7b18167aba80 (diff)
added sorting (via drag and drop) and deleting of menu items. Its not perfect though and needs more styling. I'm unsure about the proper route for the sort action. Will investigate.
Diffstat (limited to 'app/controllers/menu_items_controller.rb')
-rw-r--r--app/controllers/menu_items_controller.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb
index 7b71693..dac78d9 100644
--- a/app/controllers/menu_items_controller.rb
+++ b/app/controllers/menu_items_controller.rb
@@ -3,7 +3,7 @@ class MenuItemsController < ApplicationController
3 layout 'admin' 3 layout 'admin'
4 4
5 def index 5 def index
6 @menu_items = MenuItem.all 6 @menu_items = MenuItem.all(:order => "position ASC")
7 end 7 end
8 8
9 def show 9 def show
@@ -35,7 +35,19 @@ class MenuItemsController < ApplicationController
35 end 35 end
36 end 36 end
37 37
38 def delete 38 def destroy
39 menu_item = MenuItem.find( params[:id] )
40 menu_item.destroy
41 redirect_to menu_items_path
42 end
43
44 def sort
45 params[:menu_items].each_with_index do |item_id, index|
46 menu_item = MenuItem.find(item_id)
47 menu_item.update_attributes(:position => index + 1)
48 end
49
50 render :nothing => true
39 end 51 end
40 52
41end 53end