This commit is contained in:
2025-07-08 02:41:31 +09:00
parent 57070ed49b
commit 56967a105e
2 changed files with 19 additions and 6 deletions
+17 -5
View File
@@ -23,10 +23,22 @@ class UsersController < ApplicationController
def me
user = User.find_by(inheritance_code: params[:code])
render(if user
{ json: user.slice(:id, :name, :inheritance_code, :role) }
else
{ json: { error: 'not found' }, status: :not_found }
end)
return head :not_found unless user
render json: user.slice(:id, :name, :inheritance_code, :role)
end
def update
user = current_user
return head :unauthorized if user&.id != params[:id].to_i
name = params[:name]
return head :bad_request if name.blank?
if user.update(name:)
render json: user.slice(:id, :name, :inheritance_code, :role), status: :created
else
render json: user.errors, status: :unprocessable_entity
end
end
end