Forum: Ruby on Rails read paramater from request

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.
Mohamed (Guest)
on 2007-07-03 01:08
how to read variable value from request dynamically
i.e.

request contains variable with these names 1,2,3,4,5.............,n

how to read these variable with loop
i tried this code but it doesn't work

i = 1
while (input=params[:'#{i}'] != nil)
puts input
i = i +1
end

please i want the right code

thx
Jon G. (Guest)
on 2007-07-03 01:12
(Received via mailing list)
Mohamed wrote:
> puts input
> i = i +1
> end
>
> please i want the right code
>
> thx
>
>
Try

params.keys.sort.each do |key|
   puts params[key]
end

--
http://www.5valleys.com/
Mohamed (Guest)
on 2007-07-03 01:30
thanks (Y)
This topic is locked and can not be replied to.