Class: ReturnsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/returns_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/returns_controller.rb', line 2

def create
  order = Order.find(params[:order_id])
  items = params[:items].collect { |item_id| Item.find(item_id) }

  @return = Return.new(order, items)
  @return.submit

  if @return.successful?
    flash[:notice] = "Successfully returned #{@return.items.size} tickets."
  else
    flash[:error] = "Unable to return tickets."
  end

  redirect_to order_url(order)
end