Files
danbooru/app/controllers/ip_bans_controller.rb
evazion a5ab25d0ba pagination: avoid counting pages outside searches.
Replace this common pattern in controllers:

    @tags = Tag.search(search_params).paginate(params[:page], :limit => params[:limit], :search_count => params[:search])

with this:

    @tags = Tag.paginated_search(params)

`search_count` is used to skip doing a full page count when we're not
doing a search (on the assumption that the number of results will be
high when not constrained by a search). We didn't do this consistently
though. Refactor to do this in every controller.
2019-10-07 22:02:03 -05:00

35 lines
670 B
Ruby

class IpBansController < ApplicationController
respond_to :html, :xml, :json, :js
before_action :moderator_only
def new
@ip_ban = IpBan.new
end
def create
@ip_ban = IpBan.create(ip_ban_params)
respond_with(@ip_ban, :location => ip_bans_path)
end
def index
@ip_bans = IpBan.includes(:creator).paginated_search(params)
respond_with(@ip_bans)
end
def destroy
@ip_ban = IpBan.find(params[:id])
@ip_ban.destroy
respond_with(@ip_ban)
end
private
def ip_ban_params
params.fetch(:ip_ban, {}).permit(%i[ip_addr reason])
end
def search_params
params.fetch(:search, {}).permit(%i[ip_addr order])
end
end