Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paging request sent to wrong route in Rails 3.2 app search #386

Open
emclab opened this issue Jun 13, 2014 · 2 comments
Open

Paging request sent to wrong route in Rails 3.2 app search #386

emclab opened this issue Jun 13, 2014 · 2 comments

Comments

@emclab
Copy link

emclab commented Jun 13, 2014

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.

@arbesulo
Copy link

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" notifications@github.com 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
#386.

@mislav
Copy link
Owner

mislav commented Jun 18, 2014

@emclab Did you solve your problem? It's probably a routing issue in your app, and most likely not a bug with will_paginate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants