/bans: avoid N+1 queries for user, banner.

Avoids an N+1 issue when rendering users with link_to_user.
This commit is contained in:
evazion
2017-04-13 00:06:02 -05:00
parent 9bf1c89357
commit f6fff16e75

View File

@@ -11,9 +11,10 @@ class BansController < ApplicationController
end
def index
@bans = Ban.search(params[:search])
@bans = @bans.paginate(params[:page], :limit => params[:limit])
respond_with(@bans)
@bans = Ban.search(params[:search]).paginate(params[:page], :limit => params[:limit])
respond_with(@bans) do |fmt|
fmt.html { @bans = @bans.includes(:user, :banner) }
end
end
def show