summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2012-08-29 00:33:56 -0700
committerelijah <elijah@riseup.net>2012-08-29 00:33:56 -0700
commite4f2547fbabab8080e9a7678f38203874c52c45d (patch)
tree4dad949ae91053eb30eb3a805fc5cd2bac74c918 /lib
parentcc8c9ede76fa946c0aabf4aeba55d29963bb7047 (diff)
security bingo!
Diffstat (limited to 'lib')
-rw-r--r--lib/static_page.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/static_page.rb b/lib/static_page.rb
index 12d4948..65e9c72 100644
--- a/lib/static_page.rb
+++ b/lib/static_page.rb
@@ -8,8 +8,13 @@ class StaticPage
def limit(num)
PageArray.new(self[0..(num-1)])
end
- def order_by(attr, locale=I18n.locale)
+ def order_by(attr, options={})
+ locale = options[:locale] || I18n.locale
+ direction = options[:direction] || :asc
array = sort do |a,b|
+ if direction == :desc
+ a, b = b, a
+ end
a_prop = a.props.locale(locale).send(attr)
b_prop = b.props.locale(locale).send(attr)
if a_prop.nil? && b_prop.nil?