Class: Spree::Api::ReturnAuthorizationsController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::ReturnAuthorizationsController
- Defined in:
- app/controllers/spree/api/return_authorizations_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
- #cancel ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#cancel ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 52 def cancel @return_authorization = @order..accessible_by(current_ability, :update).find(params[:id]) if @return_authorization.cancel respond_with @return_authorization, default_template: :show else invalid_resource!(@return_authorization) end end |
#create ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 9 def create :create, ReturnAuthorization @return_authorization = @order..build() if @return_authorization.save respond_with(@return_authorization, status: 201, default_template: :show) else invalid_resource!(@return_authorization) end end |
#destroy ⇒ Object
19 20 21 22 23 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 19 def destroy @return_authorization = @order..accessible_by(current_ability, :destroy).find(params[:id]) @return_authorization.destroy respond_with(@return_authorization, status: 204) end |
#index ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 25 def index :admin, ReturnAuthorization @return_authorizations = @order..accessible_by(current_ability, :read). ransack(params[:q]).result. page(params[:page]).per(params[:per_page]) respond_with(@return_authorizations) end |
#new ⇒ Object
33 34 35 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 33 def new :admin, ReturnAuthorization end |
#show ⇒ Object
37 38 39 40 41 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 37 def show :admin, ReturnAuthorization @return_authorization = @order..accessible_by(current_ability, :read).find(params[:id]) respond_with(@return_authorization) end |
#update ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/controllers/spree/api/return_authorizations_controller.rb', line 43 def update @return_authorization = @order..accessible_by(current_ability, :update).find(params[:id]) if @return_authorization.update_attributes() respond_with(@return_authorization, default_template: :show) else invalid_resource!(@return_authorization) end end |