Files
danbooru/app/controllers/ip_bans_controller.rb
evazion 6424a4de74 Do full page counts on small index pages.
Normally we skip doing page counts on index pages when there aren't any
search filters. This is on the assumption that most index pages have
more than 1000 pages (20,000 results), so it's not worth counting them
exactly. This isn't always true, so here we turn on full counts on
certain index pages known to be small.
2019-10-28 15:18:54 -05:00

35 lines
689 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, count_pages: true)
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