Created
July 31, 2012 21:38
-
-
Save traviskroberts/3220815 to your computer and use it in GitHub Desktop.
Grab unique vintages for accounts stocks.
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
def stocked_countries | |
joins(<<END | |
INNER JOIN wine_instances wi ON wi.id = stocks.wine_instance_id | |
INNER JOIN wines w ON w.id = wine_instances.wine_id | |
INNER JOIN countries c c.id = w.country_id | |
END).select("DISTINCT(c.name) AS country_name").order("country_name").map { |v| v.country_name } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment