Key value pairs working


#1

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 R.,


#2

Am Freitag, den 23.12.2005, 08:27 +0100 schrieb Naroor R.:

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.