Created
October 6, 2011 02:11
-
-
Save reu/1266322 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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