-
Notifications
You must be signed in to change notification settings - Fork 44
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
Ari- Octos- Muncher #44
base: master
Are you sure you want to change the base?
Conversation
API MuncherWhat We're Looking For
|
root 'grub#new' | ||
get '/recipe', to: 'grub#index', as: 'grub_list' | ||
get '/recipes/:uri', to: 'grub#show', as: 'grub' | ||
get '/recipe/new', to: 'grub#new' |
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.
Two things here:
- I'm not sure that
new
is a good description of what this route is doing - something non-RESTful likesearch
might be a better name - Could you use
resources
for the index and show routes?
rescue EdamamApiWrapper::RecipeError => error | ||
flash[:status] = :failure | ||
flash[:message] = "API called failed: #{error}" | ||
redirect_back fallback_location: root_path |
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.
Here you add an error to the flash, but the code in your view to display flash errors doesn't match this format. This means that the user gets redirected to the root page with no explanation of what went wrong - not a great experience.
APP_ID = ENV["APP_ID"] | ||
BASE_URL = "https://api.edamam.com/search?" | ||
URI_BASE = "http://www.edamam.com/ontologies/edamam.owl#recipe_" | ||
FROM = 1 |
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.
BASE_URL
and URI_BASE
are very visually similar, and it's not immediately clear how they're different. Could you rename one or both to something more distinct?
response = HTTParty.get(encoded_uri) | ||
|
||
raise StandardError.new("Could not find recipe") if response == [] | ||
|
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 do a good job of checking for errors in this file!
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions