Class: Admin::Restaurants::RestaurantAddOnsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/restaurants/restaurant_add_ons_controller.rb

Overview

typed: ignore frozen_string_literal: true

Constant Summary

Constants inherited from BaseController

BaseController::INTERNAL_SERVER_ERROR_MESSAGE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseController

#destroy_session, #identity_cache_memoization, #sign_in_page, #user_developer_session

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Methods included from UpdateLocaleConcern

#setup_locale

Methods inherited from ApplicationController

#after_sign_in_path_for, #after_sign_out_path_for, #default_url_options, #identity_cache_memoization, #render_not_found, #routing_error, search_params_key=

Methods included from ControllerHelpers

#check_boolean_param, #get_banners, #inventory_params, #reservation_params

Instance Attribute Details

#restaurantObject (readonly)

Returns the value of attribute restaurant.



8
9
10
# File 'app/controllers/admin/restaurants/restaurant_add_ons_controller.rb', line 8

def restaurant
  @restaurant
end

#restaurant_add_onObject (readonly)

Returns the value of attribute restaurant_add_on.



8
9
10
# File 'app/controllers/admin/restaurants/restaurant_add_ons_controller.rb', line 8

def restaurant_add_on
  @restaurant_add_on
end

Instance Method Details

#listObject



20
21
22
23
# File 'app/controllers/admin/restaurants/restaurant_add_ons_controller.rb', line 20

def list
  render json: restaurant.restaurant_add_ons,
         each_serializer: Websites::RestaurantAddOnSerializer
end

#updateObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/admin/restaurants/restaurant_add_ons_controller.rb', line 10

def update
  permitted_params = params.require(:add_ons_restaurant).permit(:rank_in_restaurant_scope)
  if restaurant_add_on.update(permitted_params)
    flash[:notice] = 'Updated add-on rank in restaurant scope successfully'
  else
    flash[:alert] = restaurant_add_on.errors.full_messages.to_sentence
  end
  redirect_back fallback_location: back_fallback_location
end