when delete item options to update in menu items
This commit is contained in:
@@ -55,7 +55,25 @@ class Settings::MenuItemOptionsController < ApplicationController
|
||||
# DELETE /settings/menu_item_options/1
|
||||
# DELETE /settings/menu_item_options/1.json
|
||||
def destroy
|
||||
@settings_menu_item_option.destroy
|
||||
item_option_id =@settings_menu_item_option.id
|
||||
item_option_id_string=""+item_option_id.to_s+""
|
||||
if @settings_menu_item_option.destroy
|
||||
menu_items =MenuItem.all
|
||||
menu_items.each do |item|
|
||||
if item.item_options.include?(item_option_id)
|
||||
item_update =item.item_options.reject { |i| i == item_option_id }
|
||||
item.item_code =item.item_code
|
||||
item.item_options =item_update
|
||||
item.save
|
||||
end
|
||||
if item.item_options.include?(item_option_id_string)
|
||||
item_update =item.item_options.reject { |i| i == item_option_id_string }
|
||||
item.item_code =item.item_code
|
||||
item.item_options =item_update
|
||||
item.save
|
||||
end
|
||||
end
|
||||
end
|
||||
flash[:notice] = 'Menu item option was successfully destroyed.'
|
||||
render :json => {:status=> "Success", :url => settings_menu_item_options_path }.to_json
|
||||
# respond_to do |format|
|
||||
|
||||
@@ -109,7 +109,6 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
Reference in New Issue
Block a user