Skip to content

Instantly share code, notes, and snippets.

@traviskroberts
Created July 31, 2012 21:56
Show Gist options
  • Save traviskroberts/3221018 to your computer and use it in GitHub Desktop.
Save traviskroberts/3221018 to your computer and use it in GitHub Desktop.
Grab unique vintages for accounts stocks.
def stocked_styles
joins("INNER JOIN wine_instances wi ON wi.id = stocks.wine_instance_id INNER JOIN wines w ON w.id = wi.wine_id INNER JOIN styles s ON s.id = w.style_id").select("DISTINCT(s.name) AS style_name").order("style_name").map { |s| s.style_name }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment