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.
48e2f53bc3396f2633673907dd0d62ad?d=identicon&s=25 Naroor Rathish (naroor)
on 2005-12-23 08: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 Rathish,
www.naroor.blogspot.com
953c18019bceaa294ae0429bef6ab388?d=identicon&s=25 Norman Timmler (Guest)
on 2005-12-24 10:53
(Received via mailing list)
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.
This topic is locked and can not be replied to.