[PATCH] #url does not always generate routes with query params
Reported by GMFlash | July 8th, 2008 @ 11:30 AM | in 0.9.4
# In config/router.rb I have r.resource :posts
# Generates based on the default route, so far so good...
>> merb.url(:controller => "posts", :action => "edit", :id => 5, :foo => "bar")
=> "/posts/edit/5?foo=bar"
# Generates a named route...
>> merb.url(:edit_post, 5)
=> "/posts/5/edit"
# Uh oh! Why can't I add query params to my named route?
# Was expecting it to generate /posts/5/edit?foo=bar
>> merb.url(:edit_post, 5, :foo => "bar")
ArgumentError: wrong number of arguments (3 for 2)
from (irb):13:in `url'
from (irb):13
Comments and changes to this ticket
-

GMFlash July 8th, 2008 @ 11:35 AM
- → Assigned user changed from Ezra Zygmuntowicz to Yehuda Katz (wycats)
-

GMFlash July 8th, 2008 @ 11:35 AM
- → Assigned user changed from Yehuda Katz (wycats) to Daniel Neighman (hassox)
-
Shay Arnett July 9th, 2008 @ 12:51 PM
- → State changed from new to open
- → Milestone changed from to 0.9.4
- → Tag changed from controller dispatch merb-core router routing to controller dispatch merb-core patch router routing
Mentioned to GMFlash that you can send a hash as the 2nd argument and include your object as :id => @foo... but still it's much cleaner this way.
Patch attached.
-

GMFlash July 9th, 2008 @ 05:03 PM
- no changes were found...
-

GMFlash July 9th, 2008 @ 05:12 PM
Shay,
Made a couple cosmetic adjustments to your patch:
Line 21:
Added spaces so it is "arg = {}" instead of "arg={}"
Lines 53, 54, and 58:
removed trailing whitespace
Lines 56 and 61:
removed the explicit {}'s to simulate how the end user would type it
It applied cleanly and all tests pass. You the man Shay! +1
-

GMFlash July 9th, 2008 @ 05:13 PM
- → Title changed from #url does not always generate routes with query params to [PATCH] #url does not always generate routes with query params
-

Daniel Neighman July 11th, 2008 @ 09:13 PM
- → Assigned user changed from Daniel Neighman (hassox) to Shay Arnett
-
Michael Klishin (antares) August 1st, 2008 @ 07:36 AM
- → Assigned user changed from Shay Arnett to Michael Klishin (antares)
- → State changed from open to resolved
Applied, thanks. Router and generation is being reworked by Carl Lerche, though.
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 »
