Class: Stay::Api::V1::RoomTypesController

Inherits:
BaseApiController
  • Object
show all
Defined in:
app/controllers/stay/api/v1/room_types_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



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

#showObject



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