Skip to content

Instantly share code, notes, and snippets.

@mikelovesrobots
Created January 24, 2011 23:25
Show Gist options
  • Save mikelovesrobots/794204 to your computer and use it in GitHub Desktop.
Save mikelovesrobots/794204 to your computer and use it in GitHub Desktop.
named_scope :sort_string, lambda do |type|
order_string = case type
when 'score'
"score desc"
when 'date'
"created_at desc"
else
raise "Unknown type passed into sort_string: #{type.inspect}"
end
{:order => order_string}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment