Sha256: 928d51e7fd47c5b9986354c583ce46111a0f218b4ae06c6de4bc5e856017f52c
Contents?: true
Size: 1.08 KB
Versions: 2
Compression:
Stored size: 1.08 KB
Contents
module ResourcesController module ActsAsListConcern extend ActiveSupport::Concern def reposition @resource = load_resource @dropped_resource = load_resource_scope.find(params[:dropped_id]) @dropped_resource.set_list_position(@resource.position) position = @dropped_resource.position < @resource.position ? :before : :after label_methods = [:human, :name, :title, :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("acts_as_list.flash.actions.reposition.inserted_#{position}", target_resource: target_resource_label, inserted_resource: inserted_resource_label) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails-add_ons-2.2.1 | app/concerns/resources_controller/acts_as_list_concern.rb |
rails-add_ons-2.2.0 | app/concerns/resources_controller/acts_as_list_concern.rb |