Git Product home page Git Product logo

oo-mini-project-nyc-web-062518's Introduction

OO Recipes Mini Project

In this project, we will be practicing object relationships in Ruby, with a particular emphasis on the has-many-through relationship. We will be building out a domain model in which a User has a collection of RecipeCards. Each RecipeCard will store information about a Recipe a User would like to save, creating the relationship of a User having many Recipes through RecipeCards. A single Recipe can also belong to many Users. A Recipe also has many Ingredients, while a single Ingredient can be found in many Recipes. There are Ingredients that some Users may be allergic to. Read through the deliverables below to begin building out the following six classes and to figure out additional information about their relationships. (Note - a # symbol represents an instance method, while a . represents a class method.) You may not be able to build out all methods until you have set up relationships between the classes, so it is normal to jump around a bit in the building process. If you are confused about how the below models relate to each other, it may help to draw this out on a whiteboard before beginning to code.

Testing

We've provided you with a console that you can use to test your code. To enter a console session, run ruby tools/console.rb. You'll be able to test out the methods that you write here.

Deliverables

Recipe

Build the following methods on the Recipe class

  • Recipe.all should return all of the recipe instances
  • Recipe.most_popular should return the recipe instance with the highest number of users (the recipe that has the most recipe cards)
  • Recipe#users should return the user instances who have recipe cards with this recipe
  • Recipe#ingredients should return all of the ingredients in this recipe
  • Recipe#allergens should return all of the ingredients in this recipe that are allergens
  • Recipe#add_ingredients should take an array of ingredient instances as an argument, and associate each of those ingredients with this recipe

User

Build the following methods on the User class

  • User.all should return all of the user instances
  • User#recipes should return all of the recipes this user has recipe cards for
  • User#add_recipe_card should accept a recipe instance as an argument, as well as a date and rating, and create a new recipe card for this user and the given recipe
  • User#declare_allergen should accept an ingredient instance as an argument, and create a new allergen instance for this user and the given ingredient
  • User#allergens should return all of the ingredients this user is allergic to
  • User#top_three_recipes should return the top three highest rated recipes for this user.
  • User#most_recent_recipe should return the recipe most recently added to the user's cookbook.

RecipeCard

A RecipeCard is the join between a user instance and a recipe instance. This is a has-many-through relationship. Build the following methods on the RecipeCard class:

  • RecipeCard.all should return all of the RecipeCard instances
  • RecipeCard#date should return the date of the entry
  • RecipeCard#rating should return the rating (an integer) a user has given their entry
  • RecipeCard#user should return the user to which the entry belongs
  • RecipeCard#recipe should return the recipe to which the entry belongs

Ingredient

Build the following methods on the Ingredient class

  • Ingredient.all should return all of the ingredient instances
  • Ingredient.most_common_allergen should return the ingredient instance that the highest number of users are allergic to

RecipeIngredient

RecipeIngredient is the join between an ingredient and a recipe. This is a has-many-through relationship Build the following methods on the RecipeIngredient class

  • RecipeIngredient.all should return all of the RecipeIngredient instances
  • RecipeIngredient#ingredient should return the ingredient instance
  • RecipeIngredient#recipe should return the recipe instance

Allergen

An Allergen is a join between a user and an ingredient. This is a has-many-through relationship. What methods should an instance of this model respond to?

  • Allergen.all should return all of the Allergen instances

**Bonus**

  • User#safe_recipes should return all recipes that do not contain ingredients the user is allergic to
  • What other methods might be useful to have?

oo-mini-project-nyc-web-062518's People

Contributors

lkwlala avatar meryldakin avatar perpepajn25 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.