Class: Stall::LineItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/stall/line_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  if service.call
    @quantity = params[:line_item][:quantity].to_i
    @line_item = service.line_item
    # Allow subclasses to hook into successful product list add
    yield(true) if block_given?
    # We do not render if the yield bock already has done it
    render partial: 'added' unless response_body
  else
    @line_item = service.line_item
    # Allow subclasses to hook into failed product list add
    yield(false) if block_given?
    # We do not render if the yield bock already has done it
    render partial: 'add_error' unless response_body
  end
end