Class: Spree::Api::AddressBooksController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::AddressBooksController
- Defined in:
- app/controllers/spree/api/address_books_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
- #destroy ⇒ Object
- #show ⇒ Object
-
#update ⇒ Array
Update a user’s address book by adding an address to it or by updating the associated UserAddress (e.g. making it the default).
Instance Method Details
#destroy ⇒ Object
39 40 41 42 43 44 |
# File 'app/controllers/spree/api/address_books_controller.rb', line 39 def destroy :remove_from_address_book, address_book_user address_book_user.remove_from_address_book(params[:address_id]) render :show, status: :ok end |
#show ⇒ Object
9 10 11 12 13 |
# File 'app/controllers/spree/api/address_books_controller.rb', line 9 def show :show, address_book_user render :show, status: :ok end |
#update ⇒ Array
Update a user’s address book by adding an address to it or by updating the associated UserAddress (e.g. making it the default).
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/api/address_books_controller.rb', line 26 def update :save_in_address_book, address_book_user address_params = address_book_params default_flag = address_params.delete(:default) @address = address_book_user.save_in_address_book(address_params, default_flag) if @address.valid? render :show, status: :ok else invalid_resource!(@address) end end |