Skip to content

Instantly share code, notes, and snippets.

@chandresh
Created June 20, 2013 00:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chandresh/5819235 to your computer and use it in GitHub Desktop.
Save chandresh/5819235 to your computer and use it in GitHub Desktop.
home work
Home Work
1. Take your template
2. Create the mongoid based project
3.
- Admin can create categories
- Admin can create products
- Admin can view orders
- Visitors/Buyers can view products
- Visitors/Buyers can search products
- Visitors/Buyers can add products to their cart
- Visitors/Buyers can checkout and submit an order
For the Cart:
application_controller
def current_cart
session[:cart_id] = (Cart.create).id if session[:cart_id].blank?
@cart ||= Cart.find(session[:cart_id])
end
helper_method :current_cart
Categories
products
Cart -> there is nothing other than id
line_items
products
Order -> shipping details
line_items
products
On checkout, we move the line_items from the current_cart to the orders
Order embeds_many line_items
LineItem has_many products
def current_order
session[:order_id] = (Order.create).id if session[:order_id].blank?
@order ||= Order.find(session[:order_id])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment