Forum: Ruby on Rails key value pairs working

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Naroor R. (Guest)
on 2005-12-23 09:27
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.,
www.naroor.blogspot.com
Norman T. (Guest)
on 2005-12-24 11:53
(Received via mailing list)
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.
This topic is locked and can not be replied to.