Rails app for a basic store with products, shopping cart, orders and users.
Gems:
- Devise
- CanCanCan
- Carrierwave + Cloudinary
These are the steps I followed when working on this app:
- Define data-model
- Define screen flow
- Product_type
-
name:string
-
description:text
-
image:string
-
has_many :products
- Product
-
name:string
-
description:text
-
image:string
-
price:float
-
belongs_to :product_type
-
belongs_to :inventory
-
has_many :line_items
- Inventory
-
quantity:integer
-
has_many :products
- Cart
- has_many :line_items
- Line_item
-
price (empty till checkout?)
-
quantity
-
belongs_to :cart
-
belongs_to :product
-
belongs_to :order
- Order
-
belongs_to :user
-
has_many :line_items
-
model method: availability_check()
- User
-
standard devise fields (email, password)
-
has_one :profile
-
has_many :orders
- Profile
-
name:string
-
address:string
-
image:string
-
authorization_level
-
belongs_to :user
-- Session:
- session[cart_id, user_id]
-- availability_check
- product with quantity 0 cannot be added to cart (button "AddToCart" disabled). Method in product model.
- Every time quantity in cart is changed, availability should be checked
- When you add the same product to the cart, availability should be checked
-- cart line items
- When the same product is added to cart, only the quantity should change
-- update Inventory
- git
-- cart management
- at checkout, line items are copied from cart to order
- at place order, cart is destroyed
- Product page:
-
AddToCart button on product calls method Order.add_to_cart(session, product)
- add_to_cart method checks if a cart exist in the session.
- If yes, it checks if the cart contains the product.
- if no, it creates a new line item hash with product and quantity 1
-> Entry point from wherever if cart is not empty (via some "go to cart" button)
- Pre-populates a new order form (Orders#new) with session[cart] details
- Order new page:
- Page has a 3 buttons: "Back to products" - "Update" - "Place order"
- Back to products
- just a link that re-directs you to the Products#index
- Update
- For now, just replaces the session[:cart] with whatever is in the form
- And stays on the page with just a message "Cart updated"
- Place order
- Form data is posted to Orders table creating an order (Orders#create)
- Takes you to Orders#show page for the newly created order
- Back to products
- Homepage
- Menu with user/login
- Welcome header (image/jumbotron?)
- Thumbnail for each product_type (clickable)
- Catalog page - one page for each product type
- Header with product type name, description and image
- Body with thumbnails for each product belonging to the type (clickable)
- Product page - one page for each product
- Product name, description, image
- Button "Add to cart"
- Shopping cart bar -- If not empty displayed on every page --
- List of line items with product, quantity, price, total_price_line and total_price_cart
- Button "Checkout"
- Order
- Copy of cart with line_items
- Button "Place order" to complete flow