Forum: Ruby on Rails url_for and arrays parameters (diff between 1.1.6 and 1.2.2)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E51640ebc75a902eefb2d7bc29976ca6?d=identicon&s=25 Andrew (Guest)
on 2007-03-03 04:24
Hello,

I apologize in advance if this has been brought up before, but I tried
searching the previous convos for this and didn't come up with anything.
I'm wondering if I'm experiencing a bug or expected behavior in the new
release of rails.

In Rails 1.2.2

I'm passing an array to url_for like so...
url_for :controller => 'test', :action => 'list', :fields => %w(a b c d)

and that generates...
"/test/list?fields=a%2Fb%2Fc%2Fd"

and when I look at my params object in my action fields contains a
string that looks like "a/b/c/d".  Not much of an array there (although
I can split it on the /).

When using Rails 1.1.6, the same url_for call generates...
"/test/list?fields[]=a&fields[]=b&fields[]=c&fields[]=d"

and the params object in my action contains an array like I would
expect.

I'm certain the new routing engine is causing the difference, but is
this a bug?  Can somebody please explain why I'm experiencing the
results I am?

Thanks,
Andrew
This topic is locked and can not be replied to.