Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
api: present a user object on create/update
Browse files Browse the repository at this point in the history
This is already done in other endpoints of the API, but this was weirdly
missing for users.

Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
  • Loading branch information
mssola committed Nov 15, 2017
1 parent 3c45da8 commit 8b42887
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/api/v1/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ class Users < Grape::API

post do
user = User.create declared(params)[:user]
unless user.valid?
if user.valid?
user
else
status 400
{ errors: user.errors }
end
Expand Down Expand Up @@ -135,7 +137,9 @@ class Users < Grape::API
put ":id" do
attrs = declared(params, include_missing: false)[:user]
user = User.update(params[:id], attrs)
unless user.valid?
if user.valid?
user
else
status 400
{ errors: user.errors }
end
Expand Down

0 comments on commit 8b42887

Please sign in to comment.