Class: Spree::Api::V1::ZonesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#create ⇒ Object
5
6
7
8
9
10
11
12
13
|
# File 'app/controllers/spree/api/v1/zones_controller.rb', line 5
def create
authorize! :create, Zone
@zone = Spree::Zone.new(zone_params)
if @zone.save
respond_with(@zone, status: 201, default_template: :show)
else
invalid_resource!(@zone)
end
end
|
#destroy ⇒ Object
15
16
17
18
19
|
# File 'app/controllers/spree/api/v1/zones_controller.rb', line 15
def destroy
authorize! :destroy, zone
zone.destroy
respond_with(zone, status: 204)
end
|
#index ⇒ Object
21
22
23
24
|
# File 'app/controllers/spree/api/v1/zones_controller.rb', line 21
def index
@zones = Zone.accessible_by(current_ability).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
respond_with(@zones)
end
|
#show ⇒ Object
26
27
28
|
# File 'app/controllers/spree/api/v1/zones_controller.rb', line 26
def show
respond_with(zone)
end
|
#update ⇒ Object
30
31
32
33
34
35
36
37
|
# File 'app/controllers/spree/api/v1/zones_controller.rb', line 30
def update
authorize! :update, zone
if zone.update(zone_params)
respond_with(zone, status: 200, default_template: :show)
else
invalid_resource!(zone)
end
end
|