diff options
author | HombreLaser <sebastian-440@live.com> | 2023-03-13 19:48:40 -0600 |
---|---|---|
committer | HombreLaser <sebastian-440@live.com> | 2023-03-13 19:48:40 -0600 |
commit | 5c899df07753a31543f8dad725a26ccddc44dfe2 (patch) | |
tree | cc13040e9f859688ec2ec454486528394bbc1cde /app/controllers/api | |
parent | 3dae1ce143d006cc75940b746a8eb74982e6e861 (diff) |
Añade método update a UserAccountsController
Diffstat (limited to 'app/controllers/api')
-rw-r--r-- | app/controllers/api/user_accounts_controller.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb index 600e168..1bbdcf5 100644 --- a/app/controllers/api/user_accounts_controller.rb +++ b/app/controllers/api/user_accounts_controller.rb @@ -6,7 +6,7 @@ module Api skip_before_action :validate_jwt, only: [:create] def show - render json: Serializers::UserAccountSerializer.new(current_user_account).serializable_hash + render json: serialized_object.serializable_hash end def create @@ -17,8 +17,20 @@ module Api render json: @user_account.errors.full_messages, status: :unprocessable_entity end + def update + if current_user_account.update(permitted_params) + render json: serialized_object.serializable_hash, status: :ok + else + render json: current_user_account.errors.full_messages, status: :unprocessable_entity + end + end + private + def serialized_object + Serializers::UserAccountSerializer.new(current_user_account) + end + def service_params { email: @user_account.email, role: @user_account.role } |