How do I find the URL of the .rhtml that's being served?

I have a utility class that’s being used inside a bunch of different
…rhtml files. Is there some sort of global variable that I can use to
figure out exactly what URL is being served? I’m thinking of something
like $PHP_SELF in PHP.

Thanks,

Francis

From: Francis Hwang [mailto:sera@fhwang.net]
Sent: Thursday, August 15, 2002 5:56 PM
To: ruby-talk ML
Subject: How do I find the URL of the .rhtml that’s being served?

I have a utility class that’s being used inside a bunch of different
…rhtml files. Is there some sort of global variable that I can use to
figure out exactly what URL is being served? I’m thinking of something
like $PHP_SELF in PHP.

Thanks,

What does $0 give you?

James

···

-----Original Message-----

Francis

The server should report this as an environment variable:

try adding $ENV.inspect in your script and look for PATH_INFO,
PATH_TRANSLATED, QUERY_STRING and SCRIPT_NAME

-billy.

···

On Fri, Aug 16, 2002 at 09:55:46AM +0900, Francis Hwang wrote:

I have a utility class that’s being used inside a bunch of different
…rhtml files. Is there some sort of global variable that I can use to
figure out exactly what URL is being served? I’m thinking of something
like $PHP_SELF in PHP.


Meisterbohne Söflinger Straße 100 Tel: +49-731-399 499-0
eLösungen 89077 Ulm Fax: +49-731-399 499-9

" JamesBritt" james@jamesbritt.com wrote in message news:CIELJOOMCFBDNHLICOEFGECICFAA.james@jamesbritt.com

What does $0 give you?

It gives me the path of the file on the server, something like

/home/francis/my_site/cgi-bin/test.rb

Where I really want to see

http://francis.test.com/cgi-bin/test.rb.

Philipp Meier meier@meisterbohne.de wrote in message news:20020816113805.GA7192@o-matic.net

The server should report this as an environment variable:

try adding $ENV.inspect in your script and look for PATH INFO,
PATH TRANSLATED, QUERY STRING and SCRIPT NAME

I tried Googling around for references of $ENV.inspect, but I didn’t
find anything that made sense to me. (Couldn’t find it in the Pickaxe
book either.) Could you be more specific about how I should do this?

Thanks,

Francis

Try this:

http://<%=$ENV[‘SERVER_NAME’]%><%=$ENV[‘REQUEST_URI’]%>

You can see what all the environment variables for a CGI request are
by looking at this webpage:

http://www.aaanime.net/access/env.pl?This_is_the_query_string

That page is written in Perl, but you get about the same environment
variables in Ruby.

···

On Mon, Aug 19, 2002 at 06:24:27AM +0900, Francis Hwang wrote:

Philipp Meier meier@meisterbohne.de wrote in message news:20020816113805.GA7192@o-matic.net

The server should report this as an environment variable:

try adding $ENV.inspect in your script and look for PATH INFO,
PATH TRANSLATED, QUERY STRING and SCRIPT NAME

I tried Googling around for references of $ENV.inspect, but I didn’t
find anything that made sense to me. (Couldn’t find it in the Pickaxe
book either.) Could you be more specific about how I should do this?

I tried Googling around for references of $ENV.inspect, but I didn’t
find anything that made sense to me. (Couldn’t find it in the Pickaxe
book either.) Could you be more specific about how I should do this?

This will display all of the enviroment variables available to the CGI
process:

Put inside some page-emitting code …

ENV.each{ |k,v|
print “#{k} = #{v}
\n”
}

James

···

Thanks,

Francis