Coder Social home page Coder Social logo

rails-flatiron-store's Introduction

Flatiron Store on Rails

We're going to build an e-commerce site! We're going to make an online store where users can browse items, put items in their carts, and buy items, which changes our inventory. We're eventually going to integrate the Stripe API to handle payments, and then integrate Segment.io to analyze user events.

NOTE: As with much of our Rails curriculum, remember to always use the --no-test-framework flag when you generate models, controllers, etc. That way, the Rails generators will not create additional tests on top of the test suite that already comes with the lesson. E.g., rails g model User username:string email:string --no-test-framework.

First iteration

Tasks:

  1. Models and Associations
  • Use the model tests to guide your model associations
  • There's a seed file with some data generated with the Faker gem.
  • Some hints:
    • We're going to treat our shopping cart like a session; a cart is instantiated and marked as a session when we add our first item to our cart.
    • line_items are like join tables between items and carts. They come into existance when we add an item to our cart.
    • Orders are instantiated during checkout and belong to a cart. They will act as a join table between a user and a cart.
    • an Item has a title, price (integer, in cents), and inventory (integer)
    • a Category has a title
    • a Line item has a quantity
    • an Order has a status and total (integer, in cents, which comes from the cart's total)
  1. Functionality through class and instance methods and controller actions
  • Use the tests to guide basic functionality
  • Our Cart should be able to:
    • add the same item more than once; the line_item's quantity should change in this event
    • display a total given the price/quantity of all line_items (think about keeping this logic out of the views!).
  • A user can buy items that they put in their cart, which changes the inventory of the item. Actual purchase functionality will come later through Stripe.
  • When a user checks out, an order object should be created. An order should have a status of "submitted" when checkout is complete, and its total should be set from the cart's total.
  1. Views for Program Flow
  • Add to cart buttons for each item
  • Navigation bar for visiting store home page and cart
  • Cart link should only be visible if user has added items to the cart (you should build helper methods in the application_controller to accomplish this)
  • Checkout link (checkout should be a POST request method on the carts controller)
  • Create a helper module in the app/helpers directory that will be used in our views to display our item prices and order and cart totals in a readable currency number (if the price is 4000 cents, display it as a readable 40.00).

Up Next

Stripe integration and order flow

View Flatiron Store on Rails on Learn.co and start learning to code for free.

rails-flatiron-store's People

Contributors

ahimmelstoss avatar deniznida avatar fislabstest avatar fs-lms-test-bot avatar gj avatar irmiller22 avatar kthffmn avatar sarogers avatar

Watchers

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

rails-flatiron-store's Issues

gen improvements

  • add_item method in cart is weird. It creates and returns a new LineItem object. Should an instance method on the Cart class be returning an instance of another class? Tests for this item are consequently weird.
  • App talks about users interacting with it, Cart class has a user_id column BUT tests and instructions do not require student to make a user class.
  • We don't have user's actually logging in via session controller. we fake the log in by adding a cart id to the sessions hash when someone starts adding items to the cart. This makes tests hard to pass b/c of caching. also if this lab is meant to be a big sum up of rails then we should have them build real sign up/sign in/sign out.
  • instructions/explanation of how shopping cart works is confusing to students. What is a LineItem, why do we need it? Why do we need a separate Order class.

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.