Code Monkey home page Code Monkey logo

hs-ruby2-teachers-guide-review-day's Introduction

Motivation / Why Should You Care?

You guys have learned A TON in the past 5 classes - MVC, forms, databases, user sessions. SO MUCH. It’s a lot to hold in your head at once, but luckily you don’t have to do that! Part of becoming a good developer is just practicing as much as possible - by building things - and getting good at knowing where to look stuff up. We are going to give you guys all day today to practice what you’ve learned so far by building a project from the ground up - the Flatiron Swag Shop!

Lesson Plan

  • Step 1. The M. Start off with one model/table for Items with the following attributes/columns:
    :name
    :image_url
    :price
    :count
    • Set up an Item class in item.rb (don't forget to inherit from from ActiveRecord::Base) and create a migration for the items table rake db:create_migration NAME="create_items". Fill in your up and down methods in the migration file then run it with rake db:migrate.
  • Step 2. Add to the database!
    • Boot up tux in your terminal and create some new items. L
    • There are links to images that students can use in the lab on Learn.co
  • Step 3 Onto the V.
    • Create an items.erb file that will display all of the merch for our store - including each item's name, photo and price.
  • Step 4
    • Set up your get '/items' route to pull all of your items from the database and display them in your new items.erb template.
  • Challenges (in the project README)
    • Set up a form that lists all the items and allows visitors to chose how many of each item they would like to order.
    • Add an inventory page that displays the count for each item.
      • Set up a form on the inventory page that lets you increase the inventory for any item. When the form is submitted, the items' inventory (count) should increase.
    • Set up a User model (with attributes for name and email) and a sign up page.
    • Set up a Purchase model that will track user's purchases.
      • This table will have two columns - user_id and item_id. Tables like this are called join tables because they connect (or join) objects from other models/tables.
      • You'll also need to set up new ActiveRecord relationships for each model. The Purchase model belongs_to users and items. The User and Item models both has_many purchases. This may seem a little strange but just roll with it.

Lab

Conclusion / So What?

You know so much! And being able to build this project on your own from the ground up is proof.

Hints and Hurdles

  • Encourage students to go back and look at how they built Fwitter - pattern matching is key!
  • Be there for support but encourage students to help each other, Google, etc. before they ask you for help.

View Motivation / Why Should You Care? on Learn.co and start learning to code for free.

hs-ruby2-teachers-guide-review-day's People

Contributors

fislabstest avatar fs-lms-test-bot avatar vanessadean avatar victhevenot avatar

Watchers

 avatar  avatar  avatar  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.