Commit 8bd5bba
Changed files (2)
app
controllers
config
app/controllers/cakes_controller.rb
@@ -2,7 +2,12 @@ class CakesController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show]
def index
- @cakes = Cake.all
+ @cakes = Cake.all(include: :category)
+ end
+
+ def n_plus_one
+ @cakes = Cake.all(include: :category)
+ render :index
end
def show
config/routes.rb
@@ -3,5 +3,8 @@ Confection::Application.routes.draw do
resources :cakes
resources :categories, :only => [:show], :path => 'c'
+
+ get 'n_plus_one', to: 'cakes#n_plus_one'
+
root :to => 'cakes#index'
end