Class: Spree::Api::StoresController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #permitted_line_item_attributes
included
Instance Method Details
#create ⇒ Object
13
14
15
16
17
18
19
20
21
22
|
# File 'app/controllers/spree/api/stores_controller.rb', line 13
def create
authorize! :create, Store
@store = 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
38
39
40
41
42
|
# File 'app/controllers/spree/api/stores_controller.rb', line 38
def destroy
authorize! :destroy, @store
@store.destroy
respond_with(@store, status: 204)
end
|
#index ⇒ Object
7
8
9
10
11
|
# File 'app/controllers/spree/api/stores_controller.rb', line 7
def index
authorize! :read, Store
@stores = Store.accessible_by(current_ability, :read).all
respond_with(@stores)
end
|
#show ⇒ Object
33
34
35
36
|
# File 'app/controllers/spree/api/stores_controller.rb', line 33
def show
authorize! :read, @store
respond_with(@store)
end
|
#update ⇒ Object
24
25
26
27
28
29
30
31
|
# File 'app/controllers/spree/api/stores_controller.rb', line 24
def update
authorize! :update, @store
if @store.update_attributes(store_params)
respond_with(@store, status: 200, default_template: :show)
else
invalid_resource!(@store)
end
end
|