Sha256: a2120922977e9f1f1ce7c1eab25222535a11c15013ddb429f02c9de7f7a35dc8
Contents?: true
Size: 498 Bytes
Versions: 5
Compression:
Stored size: 498 Bytes
Contents
module Admin module SortableController def sort self.instance_variable_set("@#{controller_name}", model_name.ordered) end def apply_sort ActiveRecord::Base.connection.transaction do params[controller_name].keys.each_with_index do |id, idx| model_name.find(id).update_attribute(:position, idx) end end redirect_to action: :index end private def model_name controller_name.classify.constantize end end end
Version data entries
5 entries across 5 versions & 1 rubygems