From: Bruce Williams Date: 2002-10-08T06:21:27+09:00 Subject: Re: eruby forms processing On Monday 07 October 2002 03:50 pm, jthorne@zixcorp.com wrote: > I am a newbie web programmer who has been told that ruby and eruby is > far superior to ASP, etc.I am trying to figure out how to process some > simple form data with eruby.Do I need to write a CGI application or can > I process the form data with eruby similar to active server pages.I am > trying to locate some code or syntax that would allow me to process a > form with method=post.I am having some trouble tracking down a decent > tutorial... > > Thanks for the help, > Jeff Jeff, IIRC eruby doesn't automatically import the parameters (ala-PHP-- and possibly ASP [?]) in any fashion, and this is the way I've always handled it. Someone may have a better suggestion... Use the CGI library. <% require 'cgi' params = CGI.new.params %> A common 'gotcha' with cgi.rb is the fact that CGI#params is a Hash of Arrays, not just a simple Hash. In most cases to access data you'll want to something like: <%= params['foo'][0] %> Playing with cgi.rb in irb will make this apparent. Happy erubying. - Bruce -- _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ Bruce Williams http://www.codedbliss.com iusris/#ruby-lang bruce@codedbliss.com _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/