Class: Spree::Api::StoresController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::StoresController
- Defined in:
- app/controllers/spree/api/stores_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/spree/api/stores_controller.rb', line 14 def create :create, Store @store = Spree::Store.new(store_params) @store.code = params[:store][:code] if @store.save respond_with(@store, status: 201, default_template: :show) else invalid_resource!(@store) end end |
#destroy ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/spree/api/stores_controller.rb', line 39 def destroy :destroy, @store @store.destroy respond_with(@store, status: 204) end |
#index ⇒ Object
8 9 10 11 12 |
# File 'app/controllers/spree/api/stores_controller.rb', line 8 def index :index, Store @stores = Spree::Store.accessible_by(current_ability).all respond_with(@stores) end |
#show ⇒ Object
34 35 36 37 |
# File 'app/controllers/spree/api/stores_controller.rb', line 34 def show :show, @store respond_with(@store) end |
#update ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'app/controllers/spree/api/stores_controller.rb', line 25 def update :update, @store if @store.update(store_params) respond_with(@store, status: 200, default_template: :show) else invalid_resource!(@store) end end |