Class: Stay::Api::V1::RoomTypesController
- Inherits:
-
BaseApiController
- Object
- BaseApiController
- Stay::Api::V1::RoomTypesController
- Defined in:
- app/controllers/stay/api/v1/room_types_controller.rb
Instance Method Summary collapse
Instance Method Details
#index ⇒ Object
4 5 6 7 |
# File 'app/controllers/stay/api/v1/room_types_controller.rb', line 4 def index @type = Stay::RoomType.all render json: { data: ActiveModelSerializers::SerializableResource.new(@type, each_serializer: RoomTypeSerializer), message: "data found", success: true }, status: :ok end |
#show ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/stay/api/v1/room_types_controller.rb', line 9 def show @type = Stay::RoomType.find_by(id: params[:id]) return render json: { error: "no data found", success: false }, status: :unprocessable_entity if @type.nil? render json: { data: RoomTypeSerializer.new(@type), message: "data found", success: true }, status: :ok end |