Sha256: 5fa7d44149bd673fc81c436d1198528197f2a11f2d071f1923428bbdc271dd9e

Contents?: true

Size: 398 Bytes

Versions: 12

Compression:

Stored size: 398 Bytes

Contents

# frozen_string_literal: true

module Occams::ReorderAction
  extend ActiveSupport::Concern

  included do
    mattr_accessor :reorder_action_resource
  end

  def reorder
    resource_class = self.class.reorder_action_resource
    (params.permit(order: [])[:order] || []).each_with_index do |id, index|
      resource_class.where(id: id).update_all(position: index)
    end
    head :ok
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
occams-1.0.8 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.7.3 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.7.2 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.7.1 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.7 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.6.1 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.6 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.5 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.4 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.3 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.2 app/controllers/concerns/occams/reorder_action.rb
occams-1.0.1 app/controllers/concerns/occams/reorder_action.rb