Class: SolidusAdmin::AddressesController

Inherits:
BaseController
  • Object
show all
Includes:
Spree::Core::ControllerHelpers::StrongParameters
Defined in:
app/controllers/solidus_admin/addresses_controller.rb

Instance Method Summary collapse

Methods included from ComponentsHelper

#component

Instance Method Details

#editObject



23
24
25
# File 'app/controllers/solidus_admin/addresses_controller.rb', line 23

def edit
  redirect_to action: :show
end

#showObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/solidus_admin/addresses_controller.rb', line 10

def show
  respond_to do |format|
    format.html do
      render component('orders/show/address').new(
        order: @order,
        user: @order.user,
        address: @address,
        type: address_type,
      )
    end
  end
end

#updateObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/solidus_admin/addresses_controller.rb', line 27

def update
  if @order.contents.update_cart(order_params)
    respond_to do |format|
      flash[:notice] = t('.success')

      format.html { redirect_to order_path(@order), status: :see_other }
      format.turbo_stream { render turbo_stream: '<turbo-stream action="refresh" />' }
    end
  else
    flash.now[:error] = @order.errors[:base].join(", ") if @order.errors[:base].any?

    respond_to do |format|
      format.html do
        render component('orders/show/address').new(
          order: @order,
          user: @order.user,
          address: @order.send("#{address_type}_address"),
          type: address_type,
        ), status: :unprocessable_entity
      end
    end
  end
end