Permalink
Browse files

Add support for single-table inheritance

  • Loading branch information...
scryptmouse committed Dec 12, 2013
1 parent 5181801 commit 8b148a240c5b1ab7b436445df7fa8c4ff8336da2
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/active_admin/sortable/controller_actions.rb
@@ -12,6 +12,7 @@ def sortable(options = {})
:max_levels => 0,
:protect_root => false,
:collapsible => false, #hides +/- buttons
+ :sti => false, # Using single-table inheritance?
:start_collapsed => false
# BAD BAD BAD FIXME: don't pollute original class
@@ -23,8 +24,10 @@ def sortable(options = {})
collection_action :sort, :method => :post do
resource_name = active_admin_config.resource_name.to_s.underscore.parameterize('_')
+ sortable_klass = options[:sti] ? resource_class.base_class : resource_class
+
records = params[resource_name].inject({}) do |res, (resource, parent_resource)|
- res[resource_class.find(resource)] = resource_class.find(parent_resource) rescue nil
+ res[sortable_klass.find(resource)] = sortable_klass.find(parent_resource) rescue nil
res
end
errors = []

0 comments on commit 8b148a2

Please sign in to comment.