I''m trying to understand how Rails parses the form parameters into a nested Hash for the params object -- can somebody point me in the right direction? It seems to have moved around a bit, especially with the 3.0 release, so I''m not sure where to look. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I believe it''s actually part of Rack. Check out the Rack::Request class, and I think you will find what you''re looking for. Specifically starting at line 165 http://github.com/chneukirchen/rack/blob/master/lib/rack/request.rb#L165 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-24 19:30 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> I''m trying to understand how Rails parses the form parameters into a > nested Hash for the params object -- can somebody point me in the > right direction?What are you trying to understand? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Oh, and also there is code in ActionController to pull the params out of the request object and into the controller, which is why you can do params[:value] in the controller. http://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal.rb#L87 On Aug 24, 3:29 pm, Tim Shaffer <timshaf...-BUHhN+a2lJ4@public.gmane.org> wrote:> I believe it''s actually part of Rack. > > Check out the Rack::Request class, and I think you will find what > you''re looking for. Specifically starting at line 165 > > http://github.com/chneukirchen/rack/blob/master/lib/rack/request.rb#L165-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m trying to understand how the forms microformat is parsed into a nested Hash. On Aug 24, 2:30 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: > > I''m trying to understand how Rails parses the form parameters into a > > nested Hash for the params object -- can somebody point me in the > > right direction? > > What are you trying to understand? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I think that''s in Rack Utilities http://github.com/chneukirchen/rack/blob/master/lib/rack/utils.rb#L57 On Aug 24, 3:57 pm, Adam Lassek <a...-gPN8Wxw1vSlFQULXSK7rhg@public.gmane.org> wrote:> I''m trying to understand how the forms microformat is parsed into a > nested Hash. > > On Aug 24, 2:30 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > > > Adam Lassek wrote: > > > I''m trying to understand how Rails parses the form parameters into a > > > nested Hash for the params object -- can somebody point me in the > > > right direction? > > > What are you trying to understand? > > > Best, > > -- > > Marnen Laibow-Koserhttp://www.marnen.org > > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-24 20:51 UTC
Re: Trying to find Rails'' parameter parsing code
[Please quote when replying] Adam Lassek wrote:> I''m trying to understand how the forms microformat is parsed into a > nested Hash.What do Rails forms have to do with microformats? And are you trying to understand the actual parsing code, or the result? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The name attribute of form fields created in the following format:
person[address][street_address]
is parsed into a nested hash that looks like:
{ :person => { :address => { :street_address => "" } } }
That''s a microformat.
On Aug 24, 3:51 pm, Marnen Laibow-Koser
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> [Please quote when replying]
>
> Adam Lassek wrote:
> > I''m trying to understand how the forms microformat is parsed
into a
> > nested Hash.
>
> What do Rails forms have to do with microformats? And are you trying to
> understand the actual parsing code, or the result?
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-24 21:06 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> The name attribute of form fields created in the following format: > > person[address][street_address] > > is parsed into a nested hash that looks like: > > { :person => { :address => { :street_address => "" } } } > > That''s a microformat.Not by any definition of that term that I''m familiar with. It''s just a hash. :) (For reference, the term "microformat" has only one meaning -- see http://en.wikipedia.org/wiki/Microformat -- and that wasn''t it. Using standard terminology helps to reduce misunderstandings.) Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
http://microformats.org/about They''re usually created with XML, but I think this still qualifies. It''s taking an established standard and extending its functionality through convention. is there a better term for what this is? On Aug 24, 4:06 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: > > The name attribute of form fields created in the following format: > > > person[address][street_address] > > > is parsed into a nested hash that looks like: > > > { :person => { :address => { :street_address => "" } } } > > > That''s a microformat. > > Not by any definition of that term that I''m familiar with. It''s just a > hash. :) > > (For reference, the term "microformat" has only one meaning -- seehttp://en.wikipedia.org/wiki/Microformat-- and that wasn''t it. Using > standard terminology helps to reduce misunderstandings.) > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-24 23:03 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> http://microformats.org/about > > They''re usually created with XML, but I think this still qualifies. > It''s taking an established standard and extending its functionality > through convention....which is not what Rails is doing here. No similarity IMHO.> > is there a better term for what this is?Isn''t it just a fairly standard use of Ruby hashes? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
The parameter is a String, which is parsed into a Hash by way of a convention. That convention is what I''m referring to as a microformat. On Aug 24, 6:03 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: > >http://microformats.org/about > > > They''re usually created with XML, but I think this still qualifies. > > It''s taking an established standard and extending its functionality > > through convention. > > ...which is not what Rails is doing here. No similarity IMHO. > > > > > is there a better term for what this is? > > Isn''t it just a fairly standard use of Ruby hashes? > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > Sent from my iPhone > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 02:31 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> The parameter is a String, which is parsed into a Hash by way of a > convention.There is no convention, really -- it''s too trivial to call it that. The HTTP parameters are already a list of name-value pairs, which is exactly what a hash is.> That convention is what I''m referring to as a microformat.Then you''re using the term idiosyncratically at best and inaccurately at worst. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I welcome an alternative term if that would be less confusing, but the fact is this convention exists and it''s not a part of any specification. I chose microformat as a description because it''s a conventional extension of an existing standard, HTTP parameters, to carry extra information e.g. nesting relationships. This is exactly the sort of thing microformats do with XHTML. So what if we''re embedding semantics into a key/value string rather than XML? To me that''s just an implementation detail. So I''m curious where this convention came from, and what precisely are the rules involved? Is there documentation for it? On Aug 24, 9:31 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: > > The parameter is a String, which is parsed into a Hash by way of a > > convention. > > There is no convention, really -- it''s too trivial to call it that. The > HTTP parameters are already a list of name-value pairs, which is exactly > what a hash is. > > > That convention is what I''m referring to as a microformat. > > Then you''re using the term idiosyncratically at best and inaccurately at > worst. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > Sent from my iPhone > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 04:16 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> I welcome an alternative term if that would be less confusing, but the > fact is this convention exists and it''s not a part of any > specification.*What* convention? What do you think goes beyond the HTTP spec here?> > I chose microformat as a description because it''s a conventional > extension of an existing standard, HTTP parameters, to carry extra > information e.g. nesting relationships. This is exactly the sort of > thing microformats do with XHTML. So what if we''re embedding semantics > into a key/value string rather than XML? To me that''s just an > implementation detail.Maybe, but the word "microformat" only refers to specific ways of abusing HTML/XML markup to add semantics. That''s not an "implementation detail" -- it''s a completely separate part of the problem domain. Anyway, the HTML microformat technique is not even remotely related to what we''re doing here. We are not "embedding semantics into a key/value string". You''re overthinking here -- it really is just the parameters as passed from the HTTP request. That''s all there is to it, I think. If you don''t think that explains everything, please state what you don''t understand and I''ll try to help.> > So I''m curious where this convention came from, and what precisely are > the rules involved? Is there documentation for it?What part don''t you understand? What do you think needs to be documented? What are you really trying to find out here? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 August 2010 05:16, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: >> I welcome an alternative term if that would be less confusing, but the >> fact is this convention exists and it''s not a part of any >> specification. > > *What* convention? What do you think goes beyond the HTTP spec here?I think I can see what the OP is getting at here, and do have some sympathy with his point of view. The rails convention is that, for example, an input field with the name person[address][street_address] is used to indicate that a hash of the form { :person => { :address => { :street_address => "" } } } should be posted and can hence be used by the controller to build the appropriate data. That is not part of the HTTP spec, it is an overlying convention using field names to indicate the type and structure of the data. In that sense it is akin to the microformat concept. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 12:00 UTC
Re: Re: Trying to find Rails'' parameter parsing code
Colin Law wrote: [...]> I think I can see what the OP is getting at here, and do have some > sympathy with his point of view. The rails convention is that, for > example, an input field with the name > person[address][street_address] > is used to indicate that a hash of the form > { :person => { :address => { :street_address => "" } } } > should be posted and can hence be used by the controller to build the > appropriate data. That is not part of the HTTP spec,I suppose it isn''t. But it''s such a trivial extension that it hardly bears a second glance. (I seem to recall that PHP does the same thing.)> it is an > overlying convention using field names to indicate the type and > structure of the data.In a sense, that''s *always* what field names do.> In that sense it is akin to the microformat > concept.That I do not agree with at all. I''m trying to see the similarity, and -- past the most trivial level -- I do not.> > ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 August 2010 13:00, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > [...] >> it is an >> overlying convention using field names to indicate the type and >> structure of the data. > > In a sense, that''s *always* what field names do. > >> In that sense it is akin to the microformat >> concept. > > That I do not agree with at all. I''m trying to see the similarity, and > -- past the most trivial level -- I do not.From http://en.wikipedia.org/wiki/Microformat: ''A microformat (sometimes abbreviated μF) is a web-based approach to semantic markup which seeks to re-use existing HTML/XHTML tags to convey metadata[1] and other attributes in web pages and other contexts that support (X)HTML, such as RSS.'' From http://en.wikipedia.org/wiki/Semantic: ''Semantics is the study of meaning. It typically focuses on the relation between signifiers, such as words, phrases, signs and symbols, and what they stand for.'' So I interpret ''semantic markup'' to be markup that indicates in some sense the meaning of the data. From http://en.wikipedia.org/wiki/Metadata: ''Metadata is loosely defined as data about data. Metadata is a concept that applies mainly to electronically archived or presented data and is used to describe the a) definition, b) structure and c) administration of data files with all contents in context to ease the use of the captured and archived data for further use.'' So the example where a field name of person[address][street_address] indicates that field content is the street address part of an address for a person seems to me could arguably fall into the definition of microformat as it is markup that provides some information about both the meaning and the structure of the data. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Using "person[address][street_address]" to denote a nested Hash structure is semantic, and it is not part of the spec. you might think it trivial, but not all frameworks behave in this way. So it is useful to note that this convention exists and explain its rules. Agreed? That''s all I''m asking after here. I''m sorry if my choice of the word "microformat" offends you so badly in this context, but then you have yet to offer an alternative. And other people on this list have understood what I meant. So maybe it''s not worth arguing about. On Aug 25, 7:00 am, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote: > > [...] > > > I think I can see what the OP is getting at here, and do have some > > sympathy with his point of view. The rails convention is that, for > > example, an input field with the name > > person[address][street_address] > > is used to indicate that a hash of the form > > { :person => { :address => { :street_address => "" } } } > > should be posted and can hence be used by the controller to build the > > appropriate data. That is not part of the HTTP spec, > > I suppose it isn''t. But it''s such a trivial extension that it hardly > bears a second glance. (I seem to recall that PHP does the same thing.) > > > it is an > > overlying convention using field names to indicate the type and > > structure of the data. > > In a sense, that''s *always* what field names do. > > > In that sense it is akin to the microformat > > concept. > > That I do not agree with at all. I''m trying to see the similarity, and > -- past the most trivial level -- I do not. > > > > > Colin > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > Sent from my iPhone > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 17:26 UTC
Re: Trying to find Rails'' parameter parsing code
Adam Lassek wrote:> Using "person[address][street_address]" to denote a nested Hash > structure is semantic,In what respect? It''s abusing a particular form of HTTP parameter name, true, but that''s about it. Rails'' reservation of HTTP parameter names "controller" and "action" might be considered semantic, but I don''t think the brackets are.> and it is not part of the spec. you might think > it trivial, but not all frameworks behave in this way. So it is useful > to note that this convention exists and explain its rules. Agreed? > That''s all I''m asking after here.Very simple. The brackets act like hash subscripts. Hashes are constructed so to make this possible. That''s all there is to it AFAIK.> > I''m sorry if my choice of the word "microformat" offends you so badly > in this context,It doesn''t offend me -- it''s just inaccurate.> but then you have yet to offer an alternative.I don''t think there is a useful word other than "mapping" or something like that.> And > other people on this list have understood what I meant. So maybe it''s > not worth arguing about.Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s not all there is to it. There is also a convention using parentheses to combine parameters together. On Aug 25, 12:26 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Adam Lassek wrote: > > Using "person[address][street_address]" to denote a nested Hash > > structure is semantic, > > In what respect? It''s abusing a particular form of HTTP parameter name, > true, but that''s about it. > > Rails'' reservation of HTTP parameter names "controller" and "action" > might be considered semantic, but I don''t think the brackets are. > > > and it is not part of the spec. you might think > > it trivial, but not all frameworks behave in this way. So it is useful > > to note that this convention exists and explain its rules. Agreed? > > That''s all I''m asking after here. > > Very simple. The brackets act like hash subscripts. Hashes are > constructed so to make this possible. That''s all there is to it AFAIK. > > > > > I''m sorry if my choice of the word "microformat" offends you so badly > > in this context, > > It doesn''t offend me -- it''s just inaccurate. > > > but then you have yet to offer an alternative. > > I don''t think there is a useful word other than "mapping" or something > like that. > > > And > > other people on this list have understood what I meant. So maybe it''s > > not worth arguing about. > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 17:44 UTC
Re: Trying to find Rails'' parameter parsing code
[Please quote when replying.] Adam Lassek wrote:> That''s not all there is to it. There is also a convention using > parentheses to combine parameters together.Never heard of this. Example? Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-25 17:48 UTC
Re: Trying to find Rails'' parameter parsing code
Marnen Laibow-Koser wrote:> [Please quote when replying.] > > Adam Lassek wrote: >> That''s not all there is to it. There is also a convention using >> parentheses to combine parameters together. > > Never heard of this. Example?Oh, wait, are you talking about the (1i) used in date selectors? So far as I know, that''s specific to the date parsing code, not a basic field combining feature.> > Best, > -- > Marnen Laibow-Koser > http://www.marnen.org > marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org-- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Okay, that''s what I needed to know. So this convention is limited to encoding nesting relationships for Hashes, denoting Array values, and it apparently originated from PHP. Still looking for the proper term for this convention, but that''s good enough for now. On Aug 25, 12:48 pm, Marnen Laibow-Koser <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Marnen Laibow-Koser wrote: > > [Please quote when replying.] > > > Adam Lassek wrote: > >> That''s not all there is to it. There is also a convention using > >> parentheses to combine parameters together. > > > Never heard of this. Example? > > Oh, wait, are you talking about the (1i) used in date selectors? So far > as I know, that''s specific to the date parsing code, not a basic field > combining feature. > > > > > Best, > > -- > > Marnen Laibow-Koser > >http://www.marnen.org > > mar...-sbuyVjPbboAdnm+yROfE0A@public.gmane.org > > -- > Posted viahttp://www.ruby-forum.com/.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 25 Aug 2010, at 19:04, Adam Lassek wrote:> Okay, that''s what I needed to know. So this convention is limited to > encoding nesting relationships for Hashes, denoting Array values, and > it apparently originated from PHP. Still looking for the proper term > for this convention, but that''s good enough for now.The concept of parsing parameters into a ''deep hash'' based on field names in square brackets was already present in the initial commit of Rails: http://github.com/rails/rails/blob/db045dbbf60b53dbe013ef25554fd013baf88134/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb#L32 As mentioned earlier, Rack adopted this convention from Rails before its 1.0 release: http://groups.google.com/group/rack-devel/browse_thread/thread/732e2c1e014bde30/4ee0135df7767f17 In this context of Rack, the common term for this seems to be ''nested parameter parsing''. The suggestion that the idea comes from PHP is probably correct, given that DHH was working in PHP before starting Rails. PHP parses parameters with names like person[address][city] into PHP''s equivalent of nested hashes, multidimensional associative arrays, and in that community the concept seems to go by some variation of ''GET/POST multi-dimensional parameters''. As a bit of history, this deep hashing was added for PHP 4.0 beta 3 back in 1999: http://svn.php.net/viewvc?view=revision&revision=12991 in response to this bug: http://bugs.php.net/bug.php?id=279 But the basic idea of using ''foo[bar]'' and ''foo[]'' as parameter names in order to get a single-level associative or indexed array seems to have been around from at least as far back as PHP 2 in 1996: http://svn.php.net/viewvc/archived/phpfi/trunk/src/type.c?view=markup&pathrev=2#l47 where it''s included with little fanfare and no specific name. No idea if this was in turn lifted from somewhere else -- if anywhere, it''d most likely be from Perl CGI conventions from around that period. Chris -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-26 04:30 UTC
Re: Re: Trying to find Rails'' parameter parsing code
Chris Mear wrote:> On 25 Aug 2010, at 19:04, Adam Lassek wrote: > >> Okay, that''s what I needed to know. So this convention is limited to >> encoding nesting relationships for Hashes, denoting Array values, and >> it apparently originated from PHP. Still looking for the proper term >> for this convention, but that''s good enough for now. > > The concept of parsing parameters into a ''deep hash'' based on field > names in square brackets was already present in the initial commit of > Rails: >[...] Thanks for the history lesson. That was fascinating. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.