Last active
July 28, 2016 03:56
-
-
Save GiancarlosIO/23cd4de484c9569fbd5e4cb4f878766e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POST api/v1/users, params: { user: {email: '[email protected]', name: 'Giancarlos Isasi' } } | |
def create | |
if params[:user] | |
@user = User.with_token(params[:user]) # le pasamos la información que nuestro metodo 'with_token' usara para crear al usuario | |
@token = @user.tokens.create() # Al usuario que nos devuelve nuestro parametro 'with_token' le creamos un nuevo token | |
render "api/v1/users/show" # en esta vista mostraremos la info del usuario y su token respectivo | |
else | |
render json: { error: 'user params info is missing' } # solo si no nos envian la info necesaria | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment