helper issue when request.method != :get
-
Matt Aimonetti (mattetti)
on suggestion to fix this problem is to add a new pagination option: pagination_action or default_action.
in the page_link_or_span method we can easily check on request.method, if we don't get a :get request and we have a pagination_action defined, we can merge the params with the pagination_action and the page info to create a proper link.
-
Matt Aimonetti (mattetti)
here is an example how what I meant earlier.
-
Mislav
- State changed from new to open
Not so simple. The helper must merge GET or POST params because the page being rendered might be a search initiated by GET or POST and I have to preserve params of the search between pages.
Can you explain better what you're doing? I didn't understand nothing about updates, panels, questions or ajax reloading. Thanks
-
Matt Aimonetti (mattetti)
I have some update and delete action called remotely which re render a div including some photos and the pagination helper.
The pagination helper is included in the div because it needs to be refreshed in case some photos were removed.
The ajax calls are using the UPDATE or DELETE methods to update or delete one or many pictures. The actions called by these remote forms have nothing to do with the action handling the pagination, however since you are merging the request params, the pagination tries to call the same action again.
I can't find a case where it would make sense for the pagination helper to make an update/delete call to any action.
Does it make more sense?
-Matt
-
Fjan
Same problem here: If you have a nice RESTful controller that renders a list right after a new item was POSTed, the will_paginate plugin will add all the POST info all the links. The classic paginator didn't do that, I wonder how they figured out which params to include. Anyway, I solved it by modifying will_paginate so I could pass in the url options, but that's not nearly as elegant as the classic plugin did it.
-
Mislav
Fjan, I don't think I'll be supporting that practice, but will definitely make this configurable. You will be able to mess with merged parameters as much as you want
-
Mislav
- State changed from open to resolved
Hey Matt, Fjan,
In changeset [422] I've stopped preserving parameters in pagination links for non-GET requests. So, obviously I listened to Matt's suggestion.
You can tamper with parameters, though:
will_paginate @posts, :params => { :foo => 'bar' }In this example, all page links will have the "foo" parameter. Similarly, with nil values you can prevent certain keys from showing up in page links.
-
Dan
so does that mean that the only way to generate links for the results of a post based search is to manually tell the will_paginate helper the url parameters for the generated links?
i.e will_paginate @collection, :params => {:controller => 'foo', :action => 'bar'}
-
Mislav
Dan: yes, and you shouldn't have POST searches anyway.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
