diff options
Diffstat (limited to 'app/controllers/menu_items_controller.rb')
| -rw-r--r-- | app/controllers/menu_items_controller.rb | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb index 808da15..1b1eb59 100644 --- a/app/controllers/menu_items_controller.rb +++ b/app/controllers/menu_items_controller.rb | |||
| @@ -2,23 +2,23 @@ class MenuItemsController < ApplicationController | |||
| 2 | 2 | ||
| 3 | # Private | 3 | # Private |
| 4 | 4 | ||
| 5 | before_filter :login_required | 5 | before_action :login_required |
| 6 | 6 | ||
| 7 | layout 'admin' | 7 | layout 'admin' |
| 8 | 8 | ||
| 9 | def index | 9 | def index |
| 10 | @menu_items = MenuItem.all(:order => "position ASC") | 10 | @menu_items = MenuItem.order("position ASC").all |
| 11 | end | 11 | end |
| 12 | 12 | ||
| 13 | def show | 13 | def show |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | def new | 16 | def new |
| 17 | @menu_item = MenuItem.new params[:menu_item] | 17 | @menu_item = MenuItem.new menu_item_params |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | def create | 20 | def create |
| 21 | if MenuItem.create( params[:menu_item] ) | 21 | if MenuItem.create( menu_item_params ) |
| 22 | redirect_to menu_items_path | 22 | redirect_to menu_items_path |
| 23 | else | 23 | else |
| 24 | render :new | 24 | render :new |
| @@ -32,7 +32,7 @@ class MenuItemsController < ApplicationController | |||
| 32 | def update | 32 | def update |
| 33 | @menu_item = MenuItem.find( params[:id] ) | 33 | @menu_item = MenuItem.find( params[:id] ) |
| 34 | 34 | ||
| 35 | if @menu_item.update_attributes( params[:menu_item] ) | 35 | if @menu_item.update( menu_item_params ) |
| 36 | redirect_to menu_items_path | 36 | redirect_to menu_items_path |
| 37 | else | 37 | else |
| 38 | render :edit | 38 | render :edit |
| @@ -48,10 +48,15 @@ class MenuItemsController < ApplicationController | |||
| 48 | def sort | 48 | def sort |
| 49 | params[:menu_items].each_with_index do |item_id, index| | 49 | params[:menu_items].each_with_index do |item_id, index| |
| 50 | menu_item = MenuItem.find(item_id) | 50 | menu_item = MenuItem.find(item_id) |
| 51 | menu_item.update_attributes(:position => index + 1) | 51 | menu_item.update(:position => index + 1) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | render :nothing => true | 54 | head :ok |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | private | ||
| 58 | |||
| 59 | def menu_item_params | ||
| 60 | params.require(:menu_item).permit(:node_id, :path, :position, :type, :type_id) | ||
| 61 | end | ||
| 57 | end | 62 | end |
