using :param_name => "something[page]" leads to invalid behavior
-
Mislav
- State changed from new to open
Thanks for the detailed report! I'll take a deeper look as soon as I'm able.
-
Yuri
Hey,
Just realized that my initial solution is not ideal.
Imagine that GET parameters were
grid[:order] = 'created_at' grid[:order_direction] = 'asc'and the page parameter name is grid[:page].
The code above (line options = params.merge(options) if @template.request.get?) will overwrite grid[:order] and grid[:order_direction], so we need recursive merge.
I added a non destructive rec_merge (core_ext.rb):
unless Hash.instance_methods.include? 'rec_merge' Hash.class_eval do def rec_merge(other) res = self.clone other.each do |key, other_value| value = res[key] if value.is_a?(Hash) and other_value.is_a?(Hash) self[key] = value.rec_merge other_value else self[key] = other_value end end res end end endand the final working version is
def url_options(page) options = ActionController::AbstractRequest.parse_query_parameters("#{param_name}=#{page}") options.keys.each do |key| options[key.intern] = options[key] options.delete(key) end options = params.rec_merge(options) if @template.request.get? options.rec_merge!(@options[:params]) if @options[:params] return options end -
Yuri
Sunday is a bad day for coding, please ignore def rec_merge(other) above, sorry, the correct version is:
def rec_merge(other) res = self.clone other.each do |key, other_value| value = res[key] if value.is_a?(Hash) and other_value.is_a?(Hash) res[key] = value.rec_merge other_value else res[key] = other_value end end res end -
Mislav
- Tag set to view, will_paginate
- Milestone order changed from 0 to 0
(from [c88edf16a8a8d5df554f89009d015561c396d1f0]) Data Mapper: fix to_a and association bug
Closes #197 using :param_name => "something[page]" leads to invalid behavior, #218, #216, #204 ActiveRecord::Associations::AssociationCollection#any? broken since rails-rev...
https://github.com/mislav/will_paginate/commit/c88edf16a8a8d5df554f...
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.