Skip to content

Instantly share code, notes, and snippets.

@LBRapid
Created November 14, 2012 15:56
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 LBRapid/4072943 to your computer and use it in GitHub Desktop.
Save LBRapid/4072943 to your computer and use it in GitHub Desktop.
def sanitize_order_by(query)
return nil unless params[:order_by]
column, direction = params[:order_by].split
column = Zone.column_names.include?(column) ? column : 'name'
direction = %w{asc desc}.include?(direction) ? direction : 'asc'
"#{column} #{direction}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment