Wiley Davis wrote:
> I'm trying to get a url from a form and return the page title of said
> url. I'm using cgi to get the web address from the url, which looks like
> this:
> 
> http://somesite.com/result.rhtml?link=http%3A%2F%2Fpracticalpedal.com
> 
> The result page embedded ruby looks like this:
> 
> <%
> require 'rubygems'
> require 'cgi'
> require 'open-uri'
> require 'hpricot'
> 
> cgi = CGI.new
> 
> @linky = cgi['link'].to_str
> 
Disclaimer: I have never used embedded ruby before. I have used the CGI 
lib, however, so here's my take.

cgi['link'] returns a string so there is no need for the TO_STR


Other than that, your code looks ok to me, so I would check your form 
data. Something like the following should get recognized by cgi.

<FORM action="form.rb" method="put">
      <INPUT type="text" name="link">
      <INPUT type="submit" value="Submit">
</FORM>

CGI is a fickle little LIB, but she'll start to do your bidding once she 
feels that you know what you are doing. Pay particular attention to the
<INPUT type="text" name ="link"> tag
If you don't specify NAME and use ID or some other thing, CGI wont read 
your code right. At least that has been my experience.

If you just can't get CGI to read the form data, you can try to access 
the data using ARGV as if the string was a command line variable to your 
script.

I hope this helps you out. Good luck.
-- 
Posted via http://www.ruby-forum.com/.