From e4f2547fbabab8080e9a7678f38203874c52c45d Mon Sep 17 00:00:00 2001 From: elijah Date: Wed, 29 Aug 2012 00:33:56 -0700 Subject: security bingo! --- lib/static_page.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') 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? -- cgit v1.2.3