Guest User

Untitled

a guest
Jul 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. class OrdersController < ApplicationController
  2. def index
  3. # Querys order table, and then retrieves each product from product table
  4. # @orders = Order.all
  5.  
  6. # Cleaner and better version
  7. # Includes the products in the query for orders
  8. # Less queries overall
  9. @orders = Order.includes(:product).all
  10. end
  11.  
  12. def show
  13. @order = Order.find(params[:id])
  14. end
  15.  
  16. def create
  17. end
  18.  
  19. def destroy
  20. end
  21.  
  22. end
Add Comment
Please, Sign In to add comment