From d9c7e05e41e898bd4f7e8eb03a469bd7c48f4cfe Mon Sep 17 00:00:00 2001 From: simplefl Date: Thu, 9 Apr 2015 15:49:35 +0200 Subject: [PATCH] Fix up/down moving. --- app/models/concerns/extra.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/concerns/extra.rb b/app/models/concerns/extra.rb index 839303a..97189c3 100644 --- a/app/models/concerns/extra.rb +++ b/app/models/concerns/extra.rb @@ -34,8 +34,8 @@ module Extra objects = self.class.all(conditions: scope, order: column) objects.each do |item| if item.id == id and n > 0 - old_position = item.read_attribute(:column) - item.update_attribute(column, objects.fetch(n-1).read_attribute(:column)) + old_position = item[column] + item.update_attribute(column, objects.fetch(n-1)[column]) objects.fetch(n-1).update_attribute(column, old_position) end n = n + 1 @@ -47,8 +47,8 @@ module Extra objects = self.class.all(conditions: scope, order: column) objects.each do |item| if item.id == id and n < (objects.length-1) - old_position = item.read_attribute(:column) - item.update_attribute(column, objects.fetch(n+1).read_attribute(:column)) + old_position = item[column] + item.update_attribute(column, objects.fetch(n+1)[column]) objects.fetch(n+1).update_attribute(column, old_position) end n = n + 1