Nested hash parameters do not work with #link_to

78 views
Skip to first unread message

François Beausoleil

unread,
Apr 3, 2007, 5:20:20 PM4/3/07
to rubyonra...@googlegroups.com
Hi all,

Is it me or should this work:

<%= link_to("link", :a => {:b => 1}) %>

I expected:
?a[b]=1

But instead I get:
?a=b1

b1 is the #to_s form of {:b => 1}.

So, are my expectations wrong, or am I right ? If I'm right, where
should I look at to patch Rails ? Just a general pointer would be
appreciated.

Thanks !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

Mislav Marohnić

unread,
Apr 4, 2007, 4:14:04 AM4/4/07
to rubyonra...@googlegroups.com
On 4/3/07, François Beausoleil <francois....@gmail.com> wrote:
Is it me or should this work:

<%= link_to("link", :a => {:b => 1}) %>

I expected: ?a[b]=1

But instead I get: ?a=b1


I tried it on edge Rails. I get what you expected:

ActionController::Routing::Routes.generate({:a => {:b=>1}}, {:controller=>'con', :action=>'act'})
#=> "/con/act?a[b]=1"

See relevant tests:
http://dev.rubyonrails.org/browser/trunk/actionpack/test/controller/url_rewriter_test.rb?rev=6380#L168

They were added in [6343]:
http://dev.rubyonrails.org/changeset/6343

François Beausoleil

unread,
Apr 4, 2007, 3:43:03 PM4/4/07
to rubyonra...@googlegroups.com
Hi !

2007/4/4, Mislav Marohnić <mislav....@gmail.com>:


> I tried it on edge Rails. I get what you expected:
>
> ActionController::Routing::Routes.generate({:a => {:b=>1}},
> {:controller=>'con', :action=>'act'})
> #=> "/con/act?a[b]=1"
>

> They were added in [6343]:
> http://dev.rubyonrails.org/changeset/6343

Ah, I tried merging that to the 1.2 stable branch, and the patch
applies cleanly except for CHANGELOG. Could somebody backport [6343]
to the Rails 1.2 branch ?

We took a decision early on to track 1.2 and not edge for now.

Mislav Marohnić

unread,
Apr 4, 2007, 3:59:12 PM4/4/07
to rubyonra...@googlegroups.com
On 4/4/07, François Beausoleil <francois....@gmail.com> wrote:
Could somebody backport [6343] to the Rails 1.2 branch ?

Depends if they consider this a feature or a defect.

François Beausoleil

unread,
Apr 4, 2007, 4:16:01 PM4/4/07
to rubyonra...@googlegroups.com
2007/4/4, Mislav Marohnić <mislav....@gmail.com>:

> On 4/4/07, François Beausoleil <francois....@gmail.com> wrote:
> > Could somebody backport [6343] to the Rails 1.2 branch ?
>
> Depends if they consider this a feature or a defect.

If it was "corrected" on trunk, I would think this is a defect that
needed correcting. Also [6343] closed three tickets, which would
imply this is something that needed work on.

Anyway, wait and see :)

Reply all
Reply to author
Forward
0 new messages