Skip to content

Instantly share code, notes, and snippets.

@solilin
Created November 5, 2020 10:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save solilin/c93d01bd82b2618e9ef7954f49f0404f to your computer and use it in GitHub Desktop.
Save solilin/c93d01bd82b2618e9ef7954f49f0404f to your computer and use it in GitHub Desktop.
class ProductsController < ApplicatinController
def orders_products
orders = Order.all
products = orders.map(&:products).flatten
@order_products = products.select do |product|
product.order.id == params[:order_id]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment