Sha256: b89456f209726ef88171355ef3475dacbb93ccb4c37553bceddd5f94975159c6

Contents?: true

Size: 368 Bytes

Versions: 7

Compression:

Stored size: 368 Bytes

Contents

module Comfy::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

7 entries across 7 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-2.0.12 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.11 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.10 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.9 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.8 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.7 app/controllers/concerns/comfy/reorder_action.rb
comfortable_mexican_sofa-2.0.6 app/controllers/concerns/comfy/reorder_action.rb