Skip to content

Commit

Permalink
limit maximum page number to avoid long running queries
Browse files Browse the repository at this point in the history
  • Loading branch information
hesslau committed Mar 10, 2019
1 parent 7f2485a commit a1a89b0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/articles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def show
end

def index
params[:page] = [Kaminari.config.max_pages,params[:page].to_i].min
@articles = @search_cache.search params[:page]
respond_with @articles
end
Expand Down
3 changes: 2 additions & 1 deletion config/initializers/kaminari_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

Kaminari.configure do |config|
config.default_per_page = 24
config.max_pages = 300 # set max_pages to avoid large queries
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
Expand Down

0 comments on commit a1a89b0

Please sign in to comment.