sinatra view helper adds duplicate params if :params keys are symbols #286

Closed
ickymettle opened this Issue Jan 12, 2013 · 1 comment

Projects

None yet

2 participants

@ickymettle

Using the sinatra view helper, if you call it will a hash of :params where the keys are symbols on subsequent page links, the params get duplicated in the url.

If you call will paginate like this:

will_paginate(@mycollection, :params => { :foo => "bar", :baz => "quux" })

The first set of paginated links work as expected:

link?page=1&foo=bar&baz=quux

Clicking on a page link, the links generated for subsequent paginated pages will have the params duplicated:

link?page=2&foo=bar&baz=quux&foo=bar&baz=quux

It appears that in the url method in the sinatra helper fetches the existing parameters, then calls params.update to merge the optional params. The issue is that params.update treats symbol keys in the optional params as unique and re-adds them.

I've made a patch to stringify the parameter keys before passing to params.update which resolves this bug. I'm a noob ruby coder so there may be a nicer way of doing this.

@mislav
Owner

Closing this in favor of #287.

(BTW, you can convert an issue into a pull-request with hub. This avoids having to open a new pull-request for the same issue.)

@mislav mislav closed this Jan 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment