Sha256: 7db5cc649710404c26421aa0fb7f00993a0cb9d1543d83edb0105f5b94150f71

Contents?: true

Size: 490 Bytes

Versions: 1

Compression:

Stored size: 490 Bytes

Contents

# frozen_string_literal: true

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
    if resource_class == ::Comfy::Cms::Page
      Comfy::Cms::Page.all.each(&:save!)
    end
    head :ok
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
comfortable_media_surfer-3.0.0 app/controllers/concerns/comfy/reorder_action.rb