Skip to content

Instantly share code, notes, and snippets.

@rsl
Created March 4, 2009 21:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsl/74022 to your computer and use it in GitHub Desktop.
Save rsl/74022 to your computer and use it in GitHub Desktop.
## Controller
# Calls with :order => order_with_default("documents.created_at", :desc)
private
def order_with_default(column, direction)
if params[:sort]
"#{params[:sort]} #{params[:direction]}, #{column} #{direction}"
else
"#{column} #{direction}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment