Class: Admin::MenuItemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Admin::MenuItemsController
- Defined in:
- app/controllers/admin/menu_items_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #reorder ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/controllers/admin/menu_items_controller.rb', line 20 def create "New", :new_admin_page_path = SpudMenuItem.new() . = .id if params[:spud_menu_item][:parent_id].blank? .parent_id = .id .parent_type = "SpudMenu" else .parent_type = "SpudMenuItem" end if .name.blank? && !.spud_page.blank? .name = .spud_page.name end if ..blank? highest_sibling = .parent..order("menu_order desc").first if !highest_sibling.blank? . = highest_sibling. + 1 end end flash[:notice] = "Menu Created successfully!" if .save respond_with ,:location => end |
#destroy ⇒ Object
71 72 73 74 75 76 |
# File 'app/controllers/admin/menu_items_controller.rb', line 71 def destroy flash[:notice] = "Menu Item removed!" if .destroy respond_with ,:location => end |
#edit ⇒ Object
47 48 49 50 51 52 53 |
# File 'app/controllers/admin/menu_items_controller.rb', line 47 def edit "Edit #{@menu_item.name}", :edit_admin_menu_menu_item_path if .parent_type == "SpudMenu" .parent_id = nil end respond_with end |
#index ⇒ Object
8 9 10 11 |
# File 'app/controllers/admin/menu_items_controller.rb', line 8 def index = ..order(:menu_order).includes(:spud_menu_items) respond_with end |
#new ⇒ Object
13 14 15 16 17 18 |
# File 'app/controllers/admin/menu_items_controller.rb', line 13 def new "New", :new_admin_page_path = ..new respond_with end |
#reorder ⇒ Object
78 79 80 81 82 83 84 85 86 |
# File 'app/controllers/admin/menu_items_controller.rb', line 78 def reorder #id param #source position #destination position #parent # @menu_items = @menu.spud_menu_items.order(:menu_order).includes(:spud_menu_items).paginate :page => params[:page] end |
#update ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/admin/menu_items_controller.rb', line 55 def update "Edit #{@menu_item.name}", :edit_admin_menu_menu_item_path if params[:spud_menu_item][:parent_id].blank? params[:spud_menu_item][:parent_type] = "SpudMenu" params[:spud_menu_item][:parent_id] = .id else params[:spud_menu_item][:parent_type] = "SpudMenuItem" end .attributes = () . = .id flash[:notice] = "Menu saved successfully!" if .save respond_with ,:location => end |