Skip to content

Instantly share code, notes, and snippets.

@mtrudel
Created November 25, 2010 19:35
Show Gist options
  • Select an option

  • Save mtrudel/715815 to your computer and use it in GitHub Desktop.

Select an option

Save mtrudel/715815 to your computer and use it in GitHub Desktop.
def record_purchase(customer, basket)
basket.each do |product|
product.buyers << customer
end
# Render these into the relation map -- this can be done out of process too
basket.each do |x|
all_products.each do |y|
intersection[x][y] = x.buyers.intersect(y.buyers).count
end
end
end
def get_related_products(product)
return intersection[product].sort
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment