Class: Spree::Api::ClassificationsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/classifications_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Instance Method Details

#updateObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/spree/api/classifications_controller.rb', line 6

def update
  authorize! :update, Product
  authorize! :update, Taxon
  classification = Spree::Classification.find_by(
    product_id: params[:product_id],
    taxon_id: params[:taxon_id]
  )
  # Because position we get back is 0-indexed.
  # acts_as_list is 1-indexed.
  classification.insert_at(params[:position].to_i + 1)
  head :ok
end