Eruby - How to get my grubby mittens on the URL?

C

Casimir P

Hi all! 8)

Suppose I have some ruby code in a .rhtml -file, which is processed by
eruby.

How can I get the url string of the page? (so I can chop it up).

Whats a good place for reference on this?

Csmr
 
J

justincollins

Casimir said:
Hi all! 8)

Suppose I have some ruby code in a .rhtml -file, which is processed by
eruby.

How can I get the url string of the page? (so I can chop it up).

Whats a good place for reference on this?

Csmr

I think this depends somewhat on your environment (it's different if you
are running from the command line versus on a web server, for example),
but try adding

puts ENV.inspect

in your .rhtml file and that should help you find what you need.

-Justin
 
C

Casimir P

Casimir P wrote:
I think this depends somewhat on your environment [deleted some]
but try adding

puts ENV.inspect

Yup. Hehe, kinda simple. Didnt find anything in-depth, but there was
enough in what I think most call the pickaxe. http://www.ruby-doc.org/docs/
ProgrammingRuby/html/web.html (see code example at the end of "Using
Eruby").

What I wanted was to see what URI was requested, the bit after the domain,
ie.:

<% puts ENV["REQUEST_URI"] %>

Now, if I only could figure out how to redirect *all* requests to one and
the same .rhtml in the site root without actually rewriting the url user
sees... Already caused a few infinite redirect loops 8)
 
J

jan.svitok

Casimir P wrote:
I think this depends somewhat on your environment [deleted some]
but try adding

puts ENV.inspect

Yup. Hehe, kinda simple. Didnt find anything in-depth, but there was
enough in what I think most call the pickaxe. http://www.ruby-doc.org/docs/
ProgrammingRuby/html/web.html (see code example at the end of "Using
Eruby").

What I wanted was to see what URI was requested, the bit after the domain,
ie.:

<% puts ENV["REQUEST_URI"] %>

Now, if I only could figure out how to redirect *all* requests to one and
the same .rhtml in the site root without actually rewriting the url user
sees... Already caused a few infinite redirect loops 8)

For an Apache example, see any rails application (even an empty one),
go to /public/ and read .htaccess
 
C

Casimir P

Casimir P wrote:
How can I get the url string of the page?

puts ENV.inspect
ie.: <% puts ENV["REQUEST_URI"] %>

Now, if I only could figure out how to redirect *all* requests to one
and the same .rhtml in the site root without actually rewriting the url
user sees... Already caused a few infinite redirect loops 8)

For an Apache example, see any rails application (even an empty one), go
to /public/ and read .htaccess

Afaik rails != eruby, but yeah, .htaccess redirects is how I managed the
infinite redirect loops 8) something like "RedirectMatch (.*)
pageengine.rhtml" etc. :)

Just want the user and spiders to see /pagename/ while in fact all
requests are handled by one file at the root.. But this is sorta offtopic
so I guess I'll take this to regexpo or apache group if I dont get it
working on my own.

Thanks for the input, everybody.

Csmr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,270
Messages
2,571,347
Members
48,032
Latest member
SantoBotto

Latest Threads

Top