diff --git a/app/controllers/creatures_controller.rb b/app/controllers/creatures_controller.rb index f3ff865..a5303d7 100644 --- a/app/controllers/creatures_controller.rb +++ b/app/controllers/creatures_controller.rb @@ -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) diff --git a/config/routes.rb b/config/routes.rb index 7638f10..f3bf35a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 ("/")