JasonKing-good_sort 0.1.10 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/lib/good_sort/sorter.rb +9 -3
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/good_sort/sorter.rb
CHANGED
@@ -28,10 +28,16 @@ module GoodSort
|
|
28
28
|
if f.is_a? Hash
|
29
29
|
f.each do |k,v|
|
30
30
|
ass = association_for( k )
|
31
|
-
|
32
|
-
|
31
|
+
if v.is_a? String
|
32
|
+
# if we're supplied a string, then assume they know what they're
|
33
|
+
# doing and just string it up
|
34
|
+
sort_fields[k.to_sym] = { :order => v, :joins => k.to_sym }
|
35
|
+
else
|
36
|
+
unless ass_has_attr( ass, v )
|
37
|
+
raise ArgumentError, "belongs_to association #{k} does not have specified column #{v}"
|
38
|
+
end
|
39
|
+
sort_fields[k.to_sym] = { :order => ass_to_table(ass) + '.' + v.to_s, :joins => k.to_sym }
|
33
40
|
end
|
34
|
-
sort_fields[k.to_sym] = { :order => ass_to_table(ass) + '.' + v.to_s, :joins => k.to_sym }
|
35
41
|
end
|
36
42
|
next
|
37
43
|
end
|