Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: How to verify cgi.params values?
Justin Collins
7/25/2006 6:39:00 PM
tesla wrote:
> Figured it out by trial and error. I was trying to strip an object so I
> datatyped it to a string and then used strip
>
> username = cgi.params['username'].to_s.strip
> profession = cgi.params['profession'].to_s.strip
>
> This works unless there is something else I should use?
> Coming from PHP so this is not easy.
>
Yes, use:
username = cgi['username'].strip
profession = cgi['profession'].strip
This will return what you are wanting. Using CGI#params[] returns an
Array for each parameter (in case it has multiple values). CGI#[]
returns just a single value (the first in the array), which is what you
want.
It was useful for me to use:
p username
p profession
to see what was going on. Then read the documentation:
http://ruby-doc.org/stdlib/libdoc/cgi/rdoc/classes/CGI/QueryExte...
Hope that helps.
-Justin
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: How to verify cgi.params values?
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password