Class: HhMenu::AddOnsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/hh_menu/add_ons_controller.rb

Instance Method Summary collapse

Instance Method Details

#detailObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/hh_menu/add_ons_controller.rb', line 2

def detail
  restaurant_add_on_relation = AddOns::Restaurant.where(add_on_id: params[:add_on_id])

  restaurant_add_on = if params[:restaurant_id].present?
                        restaurant_add_on_relation.find_by(restaurant_id: params[:restaurant_id])
                      else
                        restaurant_add_on_relation.first
                      end

  if restaurant_add_on.present?
    serializer = HhMenu::RestaurantAddOnSerializer.new(restaurant_add_on)
    render json: { success: true, restaurant_add_on: serializer.as_json }
  else
    render json: { success: false }
  end
end