mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 21:31:28 +00:00
Fix up/down moving.
This commit is contained in:
parent
35502d97d5
commit
d9c7e05e41
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue