I''ve been working through the Depot application to get back into Rails after a few years doing other things. While I was looking at some functional tests earlier I started thinking about this: put :update, id: @user.to_param, user: @input_attributes why doesn''t the "id: @..." part throw an exception? id: isn''t a symbol. Is this some sort of alternative method of declaring a hash? Is it a method call? It works, which is great, but I''d love to know why. -- 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 Oct 7, 7:45 pm, Jonathan Telfer <jntel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> I''ve been working through the Depot application to get back into Rails > after a few years doing other things. While I was looking at some > functional tests earlier I started thinking about this: > > put :update, id: @user.to_param, user: @input_attributes > > why doesn''t the "id: @..." part throw an exception? id: isn''t a > symbol. Is this some sort of alternative method of declaring a hash?Correct - ruby 1.9 added a json-ish alternative syntax for hash literals Fred> Is it a method call? > > It works, which is great, but I''d love to know why.-- 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.
Thanks for that - I won''t miss all those hash arrows. I also found more info here for anyone else who''s interested: http://devlicio.us/blogs/sergio_pereira/archive/2008/12/31/playing-with-ruby-1-9-name-parameters-sort-of.aspx On Oct 7, 9:52 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Oct 7, 7:45 pm, Jonathan Telfer <jntel...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: > > > I''ve been working through the Depot application to get back into Rails > > after a few years doing other things. While I was looking at some > > functional tests earlier I started thinking about this: > > > put :update, id: @user.to_param, user: @input_attributes > > > why doesn''t the "id: @..." part throw an exception? id: isn''t a > > symbol. Is this some sort of alternative method of declaring a hash? > > Correct - ruby 1.9 added a json-ish alternative syntax for hash > literals > > Fred > > > > > > > > > Is it a method call? > > > It works, which is great, but I''d love to know why.-- 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.