ronald.evangelista
2008-May-23 09:22 UTC
R(c,*g) helper method can''t handle nested hash input params
params= {"search"=>"Search", "date_begin"=>"2007-05-01", "date_type"=>"created_on", "order"=>1, "report_type"=>"year_end", "person"=> {"reply_status_id"=>"1", "created_on"=> Tue, 01 May 2007 00:00:00 +0000..Fri, 23 May 2008 00:00:00 +0000}, "date_end"=>"2008-05-23"} R(Report,params) "/report/?search=Search&date_begin=2007-05-01&date_type=created_on&order =1&report_type=year_end&person=reply_status_id1created_on2007-05-01T00%3A00%3A00 %2B00%3A00..2008-05-23T00%3A00%3A00%2B00%3A00&date_end=2008-05-23" untested fix of module Helpers method R(c,*g) def R(c,*g) p,h=/\(.+?\)/,g.grep(Hash) g-=h raise "bad route" unless u = c.urls.find{|x| break x if x.scan(p).size == g.size && /^#{x}\/?$/ =~ (x=g.inject(x){|x,a| x.sub p,C.escape((a[a.class.primary_key]rescue a))}) } h.any?? u+"?"+h[0].map{|x| k, v = x if Hash===v name_ext, val = v.to_a.pop k="#{k}[#{name_ext}]" x=[k,val] end x.map{|z| C.escape(z) }*"=" }*"&": u end hope this gets fixed in Camping 2.0