key value pairs working

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

key value pairs working

Naroor Rathish
Hi,
  can anyone tell me how is the following lines in ruby works on rails
.how is the key value pairs accessed by rails .

         params[:invoiceitem].each do |key, val|
                 @invoice.invoiceitems << InvoiceItem.new(val)
         end

Thanx and regards,
Naroor Rathish,
www.naroor.blogspot.com

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: key value pairs working

Norman Timmler
Am Freitag, den 23.12.2005, 08:27 +0100 schrieb Naroor Rathish:
> Hi,
>   can anyone tell me how is the following lines in ruby works on rails
> .how is the key value pairs accessed by rails .
>
> params[:invoiceitem].each do |key, val|
> @invoice.invoiceitems << InvoiceItem.new(val)
> end

Started writing to answer your question a few times, but everytime i
felt not rightly understood it.

One try:

If params[:invoiceitem] contains a Hash, the key valus pairs would be
accessed like from a Hash. There is no magic. params[] is a Hash by
nature.

_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails