summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-02-21 19:59:06 -0600
committerHombreLaser <sebastian-440@live.com>2023-02-21 19:59:06 -0600
commitb904941229de53660a3e37c3d0931cc3f74212bf (patch)
tree67756eef0f88f3cba4952698cd1ad1b19207d2dc /app/controllers
parentcc7948e260ce47193ee8098cf2e810219e461d00 (diff)
Añade serializador de usuarios
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/user_accounts_controller.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb
new file mode 100644
index 0000000..36359e5
--- /dev/null
+++ b/app/controllers/api/user_accounts_controller.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Api
+ # The UserAccounts controller.
+ class UserAccountsController < ApplicationController
+ def create
+ @user_account = UserAccount.new(permitted_params)
+
+ unless @user_account.save
+ render json: { errors: @user_account.errors.full_messages }, status: :unprocessable_entity
+ return
+ end
+
+ render json: Serializers::UserAccountSerializer.new(@user_account).serializable_hash
+ end
+
+ private
+
+ def permitted_params
+ params.require(:user_account).permit(:email, :first_name, :last_name, :password)
+ end
+ end
+end