Sha256: 0cabd0b673f9bc7507c790c5f71787694ff0a588c167b4f19f2935ff89578ffd

Contents?: true

Size: 997 Bytes

Versions: 46

Compression:

Stored size: 997 Bytes

Contents

module Rao
  module ResourcesController::AwesomeNestedSetConcern
    extend ActiveSupport::Concern

    def reposition
      @resource = load_resource
      @dropped_resource = resource_class.find(params[:dropped_id])
      @dropped_resource.move_to_right_of(@resource)

      label_methods = [:human, :name, :email, :to_s]

      target_resource_label = nil
      label_methods.each do |method_name|
        if @resource.respond_to?(method_name)
          target_resource_label = @resource.send(method_name)
          break
        end
      end

      inserted_resource_label = nil
      label_methods.each do |method_name|
        if @dropped_resource.respond_to?(method_name)
          inserted_resource_label = @dropped_resource.send(method_name)
          break
        end
      end

      redirect_to collection_path, notice: I18n.t("awesome_nested_set.flash.actions.reposition.notice", target_resource: target_resource_label, inserted_resource: inserted_resource_label)
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
rao-resources_controller-0.0.48.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.47.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.46.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.45.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.44.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.43.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.42.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.41.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.40.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.39.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.38.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.37.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.36.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.35.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.34.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.33.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.32.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.31.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.30.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb
rao-resources_controller-0.0.29.pre app/concerns/rao/resources_controller/awesome_nested_set_concern.rb