Class: Spree::Api::ZonesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::ZonesController
- Defined in:
- app/controllers/spree/api/zones_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'app/controllers/spree/api/zones_controller.rb', line 6 def create :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
16 17 18 19 20 |
# File 'app/controllers/spree/api/zones_controller.rb', line 16 def destroy :destroy, zone zone.destroy respond_with(zone, status: 204) end |
#index ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/spree/api/zones_controller.rb', line 22 def index @zones = Spree::Zone. accessible_by(current_ability). order('name ASC'). ransack(params[:q]). result @zones = paginate(@zones) respond_with(@zones) end |
#show ⇒ Object
34 35 36 |
# File 'app/controllers/spree/api/zones_controller.rb', line 34 def show respond_with(zone) end |
#update ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'app/controllers/spree/api/zones_controller.rb', line 38 def update :update, zone if zone.update(zone_params) respond_with(zone, status: 200, default_template: :show) else invalid_resource!(zone) end end |