Created
September 6, 2014 04:50
-
-
Save dbarrionuevo/7aa8e8210a68031c9950 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # No tiene sentido hacer tan verbosa la acción, no usa bien el respond_with | |
| def create | |
| user = User.new(user_params) | |
| if user.save | |
| render json: user, status: 201, location: [:api, user] | |
| else | |
| render json: { errors: user.errors }, status: 422 | |
| end | |
| end | |
| # Se puede reescribir así! El respond_with se encarga de los status, y de devolver los errores | |
| def create | |
| user = User.new(user_params) | |
| user.save | |
| respond_with user, location: [:api, user] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment