Created
April 5, 2012 12:40
-
-
Save jlebrech/2310776 to your computer and use it in GitHub Desktop.
Arel subqueries
This file contains 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
t=Ticket.arel_table # the arel table to extract subqueries from | |
if params[:title].length > 0 then | |
sqla = t[:title].matches("%#{params[:title]}%") | |
else | |
sqla = nil | |
end | |
if params[:from].length > 0 then | |
sqlb = t[:from].matches("%#{params[:from]}%") | |
else | |
sqlb = nil | |
end | |
if params[:includes].length > 0 then | |
sqlc = t[:includes].matches("%#{params[:includes]}%") | |
else | |
sqlc = nil | |
end | |
if params[:excludes].length > 0 then | |
sqld = t[:excludes].matches("%#{params[:excludes]}%") | |
else | |
sqld = nil | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment