mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-08-07 05:13:37 -04:00
Eager loading for frequently-accessed/database-heavy pages
This commit is contained in:
1 parent
b47771d29c
commit
656edefb5f
4 files changed
+13
-11
No files matched your search
@@ -6,10 +6,11 @@ class PlantingsController < ApplicationController
|
||||
# GET /plantings
|
||||
# GET /plantings.json
|
||||
def index
|
||||
@plantings = Planting.paginate(:page => params[:page])
|
||||
@owner = Member.find_by_slug(params[:owner])
|
||||
if @owner
|
||||
@plantings = @owner.plantings.paginate(:page => params[:page])
|
||||
@plantings = @owner.plantings.includes(:owner, :crop, :garden).paginate(:page => params[:page])
|
||||
else
|
||||
@plantings = Planting.includes(:owner, :crop, :garden).paginate(:page => params[:page])
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
@@ -22,7 +23,7 @@ class PlantingsController < ApplicationController
|
||||
# GET /plantings/1
|
||||
# GET /plantings/1.json
|
||||
def show
|
||||
@planting = Planting.find(params[:id])
|
||||
@planting = Planting.includes(:owner, :crop, :garden, :photos).find(params[:id])
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
|
||||
Reference in new issue
Block a user