Skip to content

Commit

Permalink
Fix errors when ordering using polymorphic association
Browse files Browse the repository at this point in the history
  • Loading branch information
nandalopes committed Nov 8, 2010
1 parent b3eb5e2 commit af71fe6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/searchlogic/named_scopes/association_ordering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,14 @@ def association_ordering_condition_details(name)
end

def create_association_ordering_condition(association, order_as, condition, args)
named_scope("#{order_as}_by_#{association.name}_#{condition}", association_condition_options(association, "#{order_as}_by_#{condition}", args))
cond = condition
poly_class = nil
if condition =~ /^(\w+)_type_(\w+)$/
poly_type = $1
cond = $2
poly_class = poly_type.camelcase.constantize if poly_type
end
named_scope("#{order_as}_by_#{association.name}_#{condition}", association_condition_options(association, "#{order_as}_by_#{cond}", args, poly_class))
end
end
end
Expand Down

0 comments on commit af71fe6

Please sign in to comment.