Created
October 20, 2011 14:54
-
-
Save markprovan/1301345 to your computer and use it in GitHub Desktop.
Order Controller
This file contains hidden or 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
| class MainOrderScreenController < ApplicationController | |
| def index | |
| @items = Item.all | |
| @current_order = Order.find(session[:order_id]) | |
| end | |
| def add_item_to_order | |
| @item = Item.find(params[:id]) | |
| @order = Order.new #Don't create an order until there is an item to be added to it. | |
| @order.items.push(@item) | |
| @order.save | |
| session[:order_id] = @order.id | |
| redirect_to order_home_path | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment