Git Product home page Git Product logo

active-record-pizza-lab's Introduction

ActiveRecord Models

Challenge

Your task is to write a RESTful routes & controllers for our Pizza Shop and fill in each with actual code. Earlier this week we had a skeleton, and now it's time to fill it out.

There are two important details to keep in mind. Tomorrow morning, we'll be demonstrating how to use HTML forms to send data from user input to our controller actions, which will be the final piece of the puzzle for creating a full blown web application.

  • You don't have to create the controller actions for new and edit. Skip those until tomorrow (unless you want to jump ahead on your own).
  • Hardcode your params for now. You'll need to specifically in your create and update actions. We'll get those to be real data tomorrow.
#create
post "/pizzas" do
    params = {name: "Red Anchovy Delight", sauce: 'red', cheese:true, mushrooms:true, extra_toppings: "anchovies"}
    #...

In the last 10 minutes, we'll walk through a complete solution example so you can gauge how you did!

Exercise

####Requirements

  • Write a RESTful controller for our pizza resource with index, show, create, update, and delete routes. You should be using (but not limited to) the following ActiveRecord methods:

    • .find
    • .all
    • .new
    • .save
    • .update_attributes
    • .destroy
  • Fill in each controller action with the CRUD operation that is appropriate for that action

  • Don't forget about params

Starter Code

The same code as our lesson is included in the starter-code folder. The Sinatra setup is ready to go, you just need to fill in your controller.

Deliverable

Shoot to create a complete RESTful controller with appropriate ActiveRecord methods inside and compare your work with the solution code when complete.

You'll get a lot more practice with this so don't sweat it if you're struggling, but if you are:

  • Don't freeze up, try things out
  • Read all errors carefully
  • Identify your knowledge gaps
  • Formulate a question
  • ASK THAT QUESTION!

###Resources

active-record-pizza-lab's People

Contributors

benhulan avatar

Watchers

Kabah Conda 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.