Skip to content

Instantly share code, notes, and snippets.

@tomharris
Created June 14, 2013 20:34
Show Gist options
  • Save tomharris/5785049 to your computer and use it in GitHub Desktop.
Save tomharris/5785049 to your computer and use it in GitHub Desktop.
class Thing < ActiveRecord::Base
def self.sort_by_column(column, direction)
if column_names.include?(column) and %w(asc desc).include?(direction)
order("#{column} #{direction}")
else
self
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment