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
link_to_next_page does not generate proper links with nested params as of version 1.0.0 #873
Comments
There is a test case that checks the exact same case you described above. Could you add a test that fails and send a pull request so we can replicate your issue locally? Also, as of c0619af, both the |
Thanks! Let me get jumping to the conclusion. When I remove Also, I have tried to move this line to the top of the method for checking, the problem has been solved as well. So, undoubtedly the cause of the problem is passing However, even if it is the issue caused by unusual usage, I think this behavior is not intended, and I also found that the problem is complex than I thought. I've tried to write fail tests by adding test cases with problematic params, but every test has passed. Then after further investigation, the problem occurs only when nested What makes the problem complicated is that even once nested inner params' key is directly accessed in controllers or views, that automatically changes from # in SomeController#index
p param
#=><ActionController::Parameters {"query"=>{"genre"=>"aaa"}, "controller"=>"albums", "action"=>"index"} permitted: false>
p params[:query]
#=> <ActionController::Parameters {"genre"=>"aaa"}
p param
#=> <ActionController::Parameters {"query"=><ActionController::Parameters {"genre"=>"aaa"} permitted: false>, "controller"=>"albums", "action"=>"index"} permitted: false> For the moment I'm not sure this is intended by Rails' ActonController, at least it makes difficult to point out the cause of the problem. Anyway, I'll try to write a test case to represent the above behavior when I have time (maybe weekend). But if you think there's nothing needs to be done about this issue. Plesase go ahead and close this. |
I've found the root cause of the problem and added some tests that fail. |
As of version 1.0.0,
link_to_next_page
(andlink_to_previous_page
) helper seems not to generate proper links when it receives nested params.Given the situation that you want a nested param which has
query
for its key. despite that it should be represented as a sort ofquery[genre]=crustcore
in a link href path, these helpers generate something likequery=genre=crustcore
. As a result of that, params which are available in controllers have not got parsed correctly.I have never encountered this issue when using
paginate
helper.Minimal example of code to reproduce
Assuming there is
@albums = Album.all.page(params[:page])
in your controller:Then when you add
?query[genre]=crustcore
to the current url shown in your web browser, the above example generates:on version 1.0.x
on version 0.17.0
This is the expected link.
The text was updated successfully, but these errors were encountered: