Created
June 20, 2013 00:05
-
-
Save chandresh/5819235 to your computer and use it in GitHub Desktop.
home work
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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