From fdbb97c62348039ba64b689c81c52b41007e22a0 Mon Sep 17 00:00:00 2001 From: Alessandro Date: Tue, 22 Oct 2024 14:15:24 -0300 Subject: [PATCH] Add endpoint to create skills --- app/controllers/skills_controller.rb | 5 +++-- config/routes.rb | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/skills_controller.rb b/app/controllers/skills_controller.rb index b162a15..7a4d253 100644 --- a/app/controllers/skills_controller.rb +++ b/app/controllers/skills_controller.rb @@ -1,15 +1,16 @@ # frozen_string_literal: true class SkillsController < ApplicationController + def index - @skills = Skill.all + @skills = Skill.all.sort_by(&:name) end def create @skill = Skill.new(skill_params) if @skill.save - render json: @skill, status: :created, location: @skill + render json: @skill, status: :created else render json: @skill.errors, status: :unprocessable_entity end diff --git a/config/routes.rb b/config/routes.rb index 68f384f..361f39f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,7 +35,7 @@ resources :users resources :customers resources :professions, only: [:index] - resources :skills, only: [:index] + resources :skills, only: [:index, :create] resources :issues, only: [:index] resources :permissions, only: [:index] resources :user_skills, only: [:index] do