Permalink
Browse files

Improve legibility.

  • Loading branch information...
1 parent 8b148a2 commit 05296abc1bb0c6cd1808a13687ea568ee4f9fc25 @scryptmouse committed Dec 12, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/active_admin/sortable/controller_actions.rb
@@ -30,16 +30,21 @@ def sortable(options = {})
res[sortable_klass.find(resource)] = sortable_klass.find(parent_resource) rescue nil
res
end
+
errors = []
+
ActiveRecord::Base.transaction do
records.each_with_index do |(record, parent_record), position|
record.send "#{options[:sorting_attribute]}=", position
+
if options[:tree]
record.send "#{options[:parent_method]}=", parent_record
end
+
errors << {record.id => record.errors} if !record.save
end
end
+
if errors.empty?
head 204
else

0 comments on commit 05296ab

Please sign in to comment.