I have these two tables - User, Accounts. User contains an authentication key, Accounts contains the list of accounts.
I am trying to get the list of accounts for the user if the authentication key is correct.
So in the controller I have -
def show
@user = User.where(authentication_token:params[:authentication_token])
render json: @user.as_json(only:
[:email,:id,:authentication_token]),status: :created
end
This would just return the user details. How can i edit it so it first checks if the user exists with that Authentication_token, and then uses the UserID, in the accounts table to get the list of accounts ?
Aucun commentaire:
Enregistrer un commentaire