Class: Spree::Api::AddressesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/addresses_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



8
9
10
11
12
# File 'app/controllers/spree/api/addresses_controller.rb', line 8

def show
  authorize! :show, @order, order_token
  find_address
  respond_with(@address)
end

#updateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/api/addresses_controller.rb', line 14

def update
  authorize! :update, @order, order_token
  find_address

  success = @order.update({"#{@order_source}_attributes" => address_params})
  @address = @order.send(@order_source)

  if success
    respond_with(@address, default_template: :show)
  else
    invalid_resource!(@address)
  end
end