Class: Spree::Admin::OptionTypesController

Inherits:
ResourceController show all
Defined in:
app/controllers/spree/admin/option_types_controller.rb

Instance Method Summary collapse

Methods inherited from ResourceController

belongs_to, #create, #destroy, #edit, #new, #update, #update_positions

Instance Method Details

#update_values_positionsObject



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

def update_values_positions
  ActiveRecord::Base.transaction do
    params[:positions].each do |id, index|
      Spree::OptionValue.where(id: id).update_all(position: index)
    end
  end

  respond_to do |format|
    format.html { redirect_to admin_product_variants_url(params[:product_id]) }
    format.js { render text: 'Ok' }
  end
end