diff options
Diffstat (limited to 'app/controllers/menu_items_controller.rb')
| -rw-r--r-- | app/controllers/menu_items_controller.rb | 16 |
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 | ||
| 41 | end | 53 | end |
