Skip to content

Instantly share code, notes, and snippets.

@mcelaney
Created July 5, 2016 20:41
Show Gist options
  • Save mcelaney/75ca581ba2bf9649e377ba685d2090db to your computer and use it in GitHub Desktop.
Save mcelaney/75ca581ba2bf9649e377ba685d2090db to your computer and use it in GitHub Desktop.
defmodule ProductVehicle do
def vehicles_that_fit_product(query \\ ProductVehicle, product_id) do
query
|> join(:inner,
[products_vehicles],
product in assoc(products_vehicles, :product))
|> join(:inner,
[products_vehicles],
vehicle in assoc(products_vehicles, :vehicle))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment