Skip to content
This repository was archived by the owner on Nov 22, 2022. It is now read-only.

Commit 0012c9c

Browse files
author
bgrove1974
committed
Update show method in user controller to find address by UUID or ID
1 parent cd2962f commit 0012c9c

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

app/controllers/v1/users_controller.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ def index
1111
# GET /users/1
1212
# GET /users/1.json
1313
def show
14-
@user = User.find(params[:id])
15-
16-
render json: @user, only: [:id, :token]
14+
@user = User.find_by_token(params[:id]) || User.find(params[:id])
15+
16+
render json: @user
17+
# render json: @user, only: [:id, :token]
1718
# render json: User.find(params[:id]), only: [:id]
1819
# render json: @user.id
1920
end
@@ -57,6 +58,12 @@ def issues
5758
head :ok
5859
end
5960

61+
# def token
62+
# @user = User.find_by_token(params[:id])
63+
64+
# render json: @user
65+
# end
66+
6067
# DELETE /users/1
6168
# DELETE /users/1.json
6269
# def destroy

config/routes.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
get 'users/:id/candidates' => 'users#candidates'
77
get 'users/:id/elections' => 'users#elections'
88
get 'users/:id/issues' => 'users#issues'
9+
910
resources :candidates, only: [:show], :constraints => {:format => /(json)/ }
1011
resources :elections, only: [:show], :constraints => {:format => /(json)/ }
1112
resources :issues, only: [:show], :constraints => {:format => /(json)/ }
1213
resources :users, except: [:destroy], :constraints => {:format => /(json)/ }
14+
1315
end
1416

1517
# resources :categories, :only => [:show], :constraints => {:format => /(json|xml)/}

0 commit comments

Comments
 (0)