Class: Stall::CartsController

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

Instance Method Summary collapse

Instance Method Details

#showObject



5
6
7
# File 'app/controllers/stall/carts_controller.rb', line 5

def show
  @cart = ProductList.find_by_token(params[:id]) || current_cart
end

#updateObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/stall/carts_controller.rb', line 9

def update
  respond_to do |format|
    service = Stall.config.service_for(:cart_update).new(@cart, cart_params)

    if service.call
      format.html.xhr do
        render 'show'
      end

      format.html.any do
        flash[:success] = t('stall.carts.flashes.update.success')
        redirect_to cart_path(@cart)
      end
    else
      format.html.xhr do
        render 'show'
      end

      format.html.any do
        flash[:error] = t('stall.carts.flashes.update.error')
        render 'show'
      end
    end
  end
end