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.
2366b35e3045fbee354edcbce654656b?d=identicon&s=25 Mohamed (Guest)
on 2007-07-02 23: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
3299251223f55753ec84719de39e6e53?d=identicon&s=25 Jon Garvin (Guest)
on 2007-07-02 23: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/
2366b35e3045fbee354edcbce654656b?d=identicon&s=25 Mohamed (Guest)
on 2007-07-02 23:30
thanks (Y)
This topic is locked and can not be replied to.