Skip to content

Instantly share code, notes, and snippets.

@markprovan
Created October 20, 2011 14:54
Show Gist options
  • Select an option

  • Save markprovan/1301345 to your computer and use it in GitHub Desktop.

Select an option

Save markprovan/1301345 to your computer and use it in GitHub Desktop.
Order Controller
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