-
Notifications
You must be signed in to change notification settings - Fork 4
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
Dt search #25
Dt search #25
Conversation
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.
Looking good, but the require
s in RecipesController and poros/recipe.rb go against Rails' 'convention over configuration' philosophy. There are a couple ways to structure these POROs in a way that Rails will know about them without having a require
-- the simplest being relocate the POROs folder to app/poros and then removing the require(_relative)
s RecipesController and Recipe. Another alternative would be to rename the poros folder to spoonacular, and then wrapping the PORO classes inside in a Spoonacular module so you can call Spoonacular::Recipe from the RecipesController without the require. Wrapping them in a module also puts recipe_ingredients/instructions/nutrition into the same scope so the require_relatives would become unnecessary. Brownfield came with an example of the latter structure with its models/you_tube POROs folder/module.
Sorry for the wall of text! I pushed up a branch agl_dt_search with a proof of concept if you are interested in taking a gander.
Recipe.new(recipe_json) | ||
end | ||
if @recipes.empty? | ||
flash[:error] = "Sorry, we couldn't find any recipes matching your |
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 like this part! haha
@@ -0,0 +1,24 @@ | |||
class RecipesController < ApplicationController | |||
def index | |||
recipes = SpoonacularService.new(search_params).parse_recipes |
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.
Probably a good place for a refactor later down the line.
@@ -0,0 +1,33 @@ | |||
class Recipe | |||
attr_reader :id, |
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.
Are we using this ID for something later? Do we need to expose it? - Nevermind
Oh... yeah, for the ID in the recipe show
type: @params['type'], | ||
minCalories: 0, minCholesterol: 0, | ||
minFat: 0, minProtein: 0, minCarbs: 0, minSugar: 0, minSodium: 0, | ||
number: 10, sort: 'random' }.compact |
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.
getting rid of nils, nice!
<%= text_field_tag :ingredients, nil, placeholder: "Enter your ingredients:" %><br> | ||
<h2>DIET</h2> | ||
<%= check_box_tag 'diet[]', 'vegetarian' %> | ||
<%= label_tag :vegetarian %><br> |
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.
Just a heads up... I think we'll have pretty much all of these in a container of some sort and won't need the
tags.... I think...
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.
Solid work. Everything looks good to me.
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.
Looks great David! Thanks for all your work on this and answering my questions along the way.
Completed:
Refactor:
@id, @title, @image, @ingredients, @instructions, @time, @nutrition