Class: Spree::Api::AddressesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

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
# File 'app/controllers/spree/api/addresses_controller.rb', line 14

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

  if @order.update({ "#{@order_source}_attributes" => address_params })
    @address = @order.send(@order_source)
    respond_with(@address, default_template: :show)
  else
    @address = @order.send(@order_source)
    invalid_resource!(@address)
  end
end