-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handled 404,500,422 Errors #58
Conversation
Pushed handling 404,500, etc right to development.rb
Pushed configuration for handling 404,500, etc right to development.rb
|
||
def not_found | ||
if env["REQUEST_PATH"] =~ /^\/api/ | ||
render :json => {:error => "not-found"}.to_json, :status => 404 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use the new hash syntax here: json: {error: 'not-found'}.to_json, status: 404
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lolll. @luizvarela right.
Pushed configuration for handling 404,500, etc right to development.rb
|
||
def not_found | ||
if env["REQUEST_PATH"] =~ /^\/api/ | ||
render :json => {:error => "not-found"}.to_json, :status => 404 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a simple rescue_from
will solve this problem to handle errors on the api side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luizvarela But talk of rescue_from
, hope this wont rescue something else. Often am advised not to use it. Can you refactor this and well secured enough and let's see whats up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can send a pull request later using the rescue_from
approach. For now, it looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you agree we Merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure @AfolabiOlaoluwa, let's do this... 👍 🎉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay. I refactored to new hash syntax
edited application_controller.rb to use new hash syntax
@luizvarela @SundayAdefila. Review this.
See graphical representation below: