Module: ControllerHelpers

Included in:
Api::Dashboard::BaseController, Api::Partner::V1::BaseController, ApplicationController
Defined in:
app/my_lib/controller_helpers.rb

Overview

typed: ignore frozen_string_literal: true

Instance Method Summary collapse

Instance Method Details

#check_boolean_param(param_value) ⇒ Object



4
5
6
# File 'app/my_lib/controller_helpers.rb', line 4

def check_boolean_param(param_value)
  ActiveRecord::Type::Boolean.new.cast(param_value)
end

#get_banners(channel) ⇒ Object



8
9
10
11
12
# File 'app/my_lib/controller_helpers.rb', line 8

def get_banners(channel)
  @banners = {
    footer: channel.channel_ads.includes(:footer_banners).select { |ad| ad.footer_banners.present? }.map(&:footer_banners).flatten
  }
end

#inventory_paramsObject



21
22
23
24
25
26
27
# File 'app/my_lib/controller_helpers.rb', line 21

def inventory_params
  params.require(:inventory).permit(:id, :start_time, :end_time, :date,
                                    :start_period, :end_period, :quantity_available,
                                    :qa, :restaurant_id).tap do |param|
                                      param[:quantity_available] = param[:qa]
                                    end
end

#reservation_paramsObject



14
15
16
17
18
19
# File 'app/my_lib/controller_helpers.rb', line 14

def reservation_params
  params.require(:reservation).permit(:name, :phone, :date, :start_time, :table, :email,
                                      :channel, :active, :party_size, :channel,
                                      :special_request, :omise_token, :restaurant_id,
                                      :adult, :kids)
end