[PATCH] Remove nil items from params hash when generating routes
Reported by GMFlash | May 7th, 2008 @ 01:28 AM
Currently when generating routes there is no easy way to remove query params. Any param assigned to nil results in a blank query param.
irb(main):001:0> Merb::Router.generate(:controller => 'cont', :action => 'act', :color => 'red', :size => nil)
=> "/cont/act?color=red&size="
----------
This patch updates the #generate method in the router to remove params that are assigned a nil value. It follows the same convention as Rails.
irb(main):001:0> Merb::Router.generate(:controller => 'cont', :action => 'act', :color => 'red', :size => nil)
=> "/cont/act?color=red"
----------
Now you are able to do something like: url(:date => (@date == Date.today) ? nil : @date))
Comments and changes to this ticket
-
Michael D. Ivey (ivey) May 7th, 2008 @ 01:40 AM
- → State changed from new to open
- → Assigned user changed from to Michael D. Ivey (ivey)
applying now
-
Michael D. Ivey (ivey) May 7th, 2008 @ 01:59 AM
- → State changed from open to resolved
committed in af5b14a3db2a0a5e025dbf64b08f5bb2f573ac02
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
