Class: Api::Aoa::V1::PackageTypesController
- Inherits:
-
BaseController
- Object
- ActionController::API
- BaseController
- Api::Aoa::V1::PackageTypesController
- Defined in:
- app/controllers/api/aoa/v1/package_types_controller.rb
Overview
package types
Constant Summary
Constants inherited from BaseController
BaseController::CACHE_NAMESPACE
Instance Method Summary collapse
Methods inherited from BaseController
Methods included from LogrageCustomLogger
Methods included from ResponseCacheConcern
Instance Method Details
#index ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/api/aoa/v1/package_types_controller.rb', line 9 def index city_id = params[:city_id] cache_key = "#{CACHE_NAMESPACE}:#{self.class}:index:#{PackageType.maximum(:updated_at)}:#{city_id}:#{MyLocaleManager.normalize_locale}" my_response_cache cache_key, :json, public: true do package_types = PackageType.where(active: true).where.not(package_type_code: 'hah') package_types = package_types.includes(:cities).joins(:cities).where(cities: { id: city_id }).group(:id) if city_id.present? Api::Aoa::V1::PackageTypeSerializer.new(package_types).as_json end end |