Created
September 2, 2016 16:53
-
-
Save icleversoft/2a7e6ee4723c238dc059f8b60b1eb5c1 to your computer and use it in GitHub Desktop.
another approach
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
tenant.invoices.joins(:line_items) | |
.includes(line_items:[:accounting]) | |
.where('line_items.type=?', 'SimpleLineItem') | |
.where('line_items.description ilike ?', '%er%') | |
.map(&:line_items).flatten | |
.map(&:description) | |
.select{|x| x.match(/er/i)} | |
.sort{|a,b| a.downcase<=>b.downcase} | |
.uniq.first(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment