Sha256: d87e8f277eb6da53a4bbaf1af2c19908c62472768ef70c60711d78972b7eca81
Contents?: true
Size: 490 Bytes
Versions: 3
Compression:
Stored size: 490 Bytes
Contents
module Admin module SortableModels 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
3 entries across 3 versions & 1 rubygems