Class: Stay::Api::V1::AmenitiesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Stay::Api::V1::AmenitiesController
- Defined in:
- app/controllers/stay/api/v1/amenities_controller.rb
Instance Method Summary collapse
Instance Method Details
#property ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/controllers/stay/api/v1/amenities_controller.rb', line 2 def property amenities = Stay::Amenity.property if amenities.exists? render json: { success: true, data: ActiveModelSerializers::SerializableResource.new(amenities, each_serializer: AmenitySerializer) }, status: :ok else render json: { success: false, message: "No property amenities found" }, status: :not_found end rescue => e render json: { success: false, error: "Failed to fetch property amenities", message: e. }, status: :internal_server_error end |
#room ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/stay/api/v1/amenities_controller.rb', line 24 def room amenities = Stay::Amenity.room if amenities.exists? render json: { success: true, data: ActiveModelSerializers::SerializableResource.new(amenities, each_serializer: AmenitySerializer) }, status: :ok else render json: { success: false, message: "No room amenities found" }, status: :not_found end rescue => e render json: { success: false, error: "Failed to fetch room amenities", message: e. }, status: :internal_server_error end |