Hi Fred,

Thanks for the response. Counter-arguments and flamebait below. :)


>> The semantic changes are as follows:
>>
>> INPUT: "a[][x]=5&a[][y]=10"
>> OLD PARSER OUTPUT: {"a" => [{"x" => "5", "y" => "10"}]}
>> NEW PARSER OUTPUT: {"a" => [{"x" => "5"}, {"y" => "10"}]}
>>
>> INPUT: "a[0][x]=5&a[0][y]=10"
>> OLD PARSER OUTPUT: {"a" => {"0" => {"x" => "5", "y" => "10"}}}
>> NEW PARSER OUTPUT: {"a" => [{"x" => "5"}, {"y" => "10"}]}
>>
>>     

First up, I made a typo in the second example. I've updated the ticket 
to reflect this. Sorry for the confusion:

INPUT: "a[0][x]=5&a[0][y]=10"
OLD PARSER OUTPUT: {"a" => {"0" => {"x" => "5", "y" => "10"}}}
NEW PARSER OUTPUT: {"a" => [{"x" => "5", "y" => "10"}]}


>> INPUT: "a[0][x]=5&a[1][y]=10"
>> OLD PARSER OUTPUT: {"a" => {"0" => {"x" => "5"}, "1" => {"y" =>  
>> "10"}}}
>> NEW PARSER OUTPUT: {"a" => [{"x" => "5"}, {"y" => "10"}]}
>>
>>
>>     
> I'm curious as to the motivation behind some of these changes.
Because Rails sucks at complex forms and I'd prefer it not to. :)

> In  
> particular the last two - is it not desirable to be able to build up  
> an array of hashes keyed by some value (whether that value happens to  
> be an index, an id or something else is a bit immaterial as far as I'm  
> concerned). ?
>   
If you're working with ActiveRecord and you want to specify an id, take 
the following example into consideration:

"parent[children][0][id]=1234&parent[children][0][name]=bob&parent[children][0][status]=ACTIVE&parent[children][1][name]=new&parent[children][1][status]=ACTIVE"

With the new parser, this would parse to:

{"parent" => {"children" => [{"id" => "1234", "name" => "bob", "status" 
=> "ACTIVE"}, {"name" => "bob", "status" => "ACTIVE"}]}}

In this manner, the elements of "children" are both logically grouped 
and ordered. Better still, this is exactly how the has_many association 
is currently modelled in ActiveRecord (i.e. has_many associations are 
arrays of ActiveRecords). Further, if no "id" attribute is set for any 
given element of "children", one can assume it is a new object rather 
than an update to an existing object. Think back to the :accessible 
option on ActiveRecord from a while back: would behaviour like this not 
have been useful?

How would you do any of this with the current parser?

I'd encourage you -- and anybody else doubting its utility -- to *try* 
the patch or the plugin in a simple application. I would be interested 
to know if you honestly thought the old parser was a better choice.

Feel free to email me directly if you have any questions or problems.

Cheers,
T


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to