diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-18 08:46:06 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-18 08:46:06 +0000 |
commit | b50adc72e533a9c20aca03063a676f6af4d32b85 (patch) | |
tree | 506e7f25effefb63ae7c8436497fd85ec0c5d410 /app/controllers/application_controller.rb | |
parent | 3affd6ab3d29bf2e86c9d4b00733499d060af20c (diff) |
Fix paging bug for type ahead search. This wasn't caught because the spec didn't call "integrate_views", so the rendering part was mocked by RSpec instead of executed.
Diffstat (limited to 'app/controllers/application_controller.rb')
-rw-r--r-- | app/controllers/application_controller.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0c8544932..2cdd5ee35 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -365,7 +365,10 @@ class ApplicationController < ActionController::Base def get_search_page_from_params return (params[:page] || "1").to_i end + def perform_search_typeahead(query, model) + @page = get_search_page_from_params + @per_page = 10 query_words = query.split(/ +(?![-+]+)/) if query_words.last.nil? || query_words.last.strip.length < 3 xapian_requests = nil @@ -376,8 +379,8 @@ class ApplicationController < ActionController::Base collapse = 'request_collapse' end options = { - :offset => 0, - :limit => 5, + :offset => (@page - 1) * @per_page, + :limit => @per_page, :sort_by_prefix => nil, :sort_by_ascending => true, :collapse_by_prefix => collapse, |