|
|
|
@ -12,4 +12,16 @@ class CreaturesController < ApplicationController
|
|
|
|
|
rescue ActiveRecord::RecordNotFound
|
|
|
|
|
render json: {}, status: 404
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
@creature = Creature.new(create_params)
|
|
|
|
|
@creature.health_points = rand(3..30)
|
|
|
|
|
@creature.save!
|
|
|
|
|
render json: @creature.as_json(only: SHOWABLE_ATTRIBUTES)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|
def create_params
|
|
|
|
|
params.require(:creature).permit(:name)
|
|
|
|
|
end
|
|
|
|
|
end
|