Skip to content

Instantly share code, notes, and snippets.

@reu
Created October 6, 2011 02:11
Show Gist options
  • Save reu/1266322 to your computer and use it in GitHub Desktop.
Save reu/1266322 to your computer and use it in GitHub Desktop.
module SugarScopes
def like(query)
relation = clone
query.each do |column, value|
relation = relation.where(arel_table[column].matches(value))
end
relation
end
def asc(column = :id)
order(column)
end
def desc(column = :id)
order(column).reverse_order
end
end
ActiveRecord::Base.send :extend, SugarScopes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment