will_paginate
will_paginate copied to clipboard
Paging request sent to wrong route in Rails 3.2 app search
When performing search on engine_config table, the first page of the search result is properly displayed. However when clicking 2nd page on the search output page, there is an error:
ActiveRecord::RecordNotFound in OnboardDataUploadx::EngineConfigsController#show
Couldn't find OnboardDataUploadx::EngineConfig with id=search_results
It seems that the controller routes to the action show to display the 2nd page. The controller should route to #search_results instead of #show and we don't why the controller does that.
Here is our routes definition in routes.rb:
resources :engine_configs do
collection do
get :search
put :search_results
end
end
In the engine configs' controller, the action search and search_results are defined as:
def search #display the page to set search parameters
@model, @search_stat = search_(params)
@results_url = 'search_results_engine_configs_path'
end
def search_results #come out with search results set above
@s_s_results_details = search_results_(params, @max_pagination)
end
The search results is stored in @s_s_results_details.models
which add pagination with models.page(params[:page]).per_page(max_pagination)
. Gem will_paginate 3.0.4 is used in the app.
Is it a bug in will_paginate? Or something wrong with the code.
Should't @results_url be = search_results_engine_configs_path instead of ' search_results_engine_configs_path'? (With no quotes) El 13/06/2014 21:59, "emclab" [email protected] escribió:
When performing search on engine_config table, the first page of the search result is properly displayed. However when clicking 2nd page on the search output page, there is an error:
ActiveRecord::RecordNotFound in OnboardDataUploadx::EngineConfigsController#show
Couldn't find OnboardDataUploadx::EngineConfig with id=search_results
It seems that the controller routes to the action show to display the 2nd page. The controller should route to #search_results instead of #show and we don't why the controller does that.
Here is our routes definition in routes.rb:
resources :engine_configs do collection do get :search put :search_results
end end
In the engine configs' controller, the action search and search_results are defined as:
def search #display the page to set search parameters @model https://github.com/model, @search_stat = search_(params) @results_url = 'search_results_engine_configs_path' end
def search_results #come out with search results set above @s_s_results_details = search_results_(params, @max_pagination) end
The search results is stored in @s_s_results_details.models which add pagination with models.page(params[:page]).per_page(max_pagination). Gem will_paginate 3.0.4 is used in the app. Is it a bug in will_paginate? Or something wrong with the code.
— Reply to this email directly or view it on GitHub https://github.com/mislav/will_paginate/issues/386.
@emclab Did you solve your problem? It's probably a routing issue in your app, and most likely not a bug with will_paginate.