2.2 - Lister les creatures

pull/1/head
Karim Bogtob 2 years ago
parent 7c3e5d79bb
commit ee35dacff7

@ -1,6 +1,11 @@
class CreaturesController < ApplicationController
SHOWABLE_ATTRIBUTES = [:id, :name, :health_points]
def index
@creatures = Creature.all
render json: @creatures.as_json(only: SHOWABLE_ATTRIBUTES)
end
def show
@creature = Creature.find(params[:id])
render json: @creature.as_json(only: SHOWABLE_ATTRIBUTES)

@ -3,6 +3,7 @@ Rails.application.routes.draw do
get '/dice-rolls/:dice_type/(:rolls_count)', to: "dice_rolls#rolls"
# CRUD Créatures
get '/creatures', to: 'creatures#index'
get '/creatures/:id', to: 'creatures#show'
# Defines the root path route ("/")

Loading…
Cancel
Save