From 13a9644bb05f7134f3ba7cb012929ee973700dc2 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Tue, 4 Jul 2023 03:21:02 -0700 Subject: [PATCH] (Hotfix) Fixes a variety of small bugs (#115) * Remove ap call * Fix remix render method * Downcase username on db end There was a bug where users with capital letters in their name could not access their profiles after we tried to make things case insensitive. * Remove ap call and unused code --- app/controllers/api/v1/parties_controller.rb | 17 ++--------------- app/controllers/api/v1/users_controller.rb | 4 ++-- app/errors/api/v1/incompatible_skill_error.rb | 1 - 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/app/controllers/api/v1/parties_controller.rb b/app/controllers/api/v1/parties_controller.rb index aa78acd..1cc1965 100644 --- a/app/controllers/api/v1/parties_controller.rb +++ b/app/controllers/api/v1/parties_controller.rb @@ -23,19 +23,6 @@ module Api party.user = current_user if current_user party.attributes = party_params if party_params - # unless party_params.empty? - # party.attributes = party_params - # - # # TODO: Extract this into a different method - # job = Job.find(party_params['job_id']) if party_params['job_id'].present? - # if job - # job_skills = JobSkill.where(job: job.id, main: true) - # job_skills.each_with_index do |skill, index| - # party["skill#{index}_id"] = skill.id - # end - # end - # end - if party.save! return render json: PartyBlueprint.render(party, view: :created, root: :party), status: :created @@ -76,8 +63,8 @@ module Api new_party.local_id = party_params[:local_id] if !party_params.nil? if new_party.save - render json: PartyBlueprint.render(new_party, view: :created, root: :party, - meta: { remix: true }) + render json: PartyBlueprint.render(new_party, view: :created, root: :party), + status: :created else render_validation_error_response(new_party) end diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 2f658a1..b1afff2 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -167,11 +167,11 @@ module Api # Specify whitelisted properties that can be modified. def set - @user = User.where('username = ?', params[:id].downcase).first + @user = User.find_by('lower(username) = ?', params[:id].downcase) end def set_by_id - @user = User.where('id = ?', params[:id]).first + @user = User.find_by('id = ?', params[:id]) end def user_params diff --git a/app/errors/api/v1/incompatible_skill_error.rb b/app/errors/api/v1/incompatible_skill_error.rb index 6168feb..6bd23dc 100644 --- a/app/errors/api/v1/incompatible_skill_error.rb +++ b/app/errors/api/v1/incompatible_skill_error.rb @@ -20,7 +20,6 @@ module Api end def to_hash - ap @data { message: message, code: code,