How to find the base URI address of a Rails site?


#1

Railsters:

Suppose I have a site hosted by a real web server, such as Apache, and
it doesn’t put the site on http://server/. Suppose it puts the site
down in http://server/path/path/path/.

If I call url_for(’/’) it just passes that thru. (Parenthetically:
Why? What’s the point?)

I need to get the complete path that the server uses to dispatch to
the base of the Rails site. Where is this crumb of data?


Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!


#2

request.host ? I think that’d work if I understand your question
correctly.

RSL


#3

Okay. Disregard my last post. I was rereading this and realized I posted
the
exact wrong answer. Sorry.

RSL


#4

Russell N. wrote:

Okay. Disregard my last post.

Yeah! You could’a found it in one Google hit:

http://www.google.com/codesearch?q=lang%3Aruby+image_path

The first citation yields

def image_path(source)
compute_public_path(source, ‘images’, ‘png’)

And compute_public_path is wisely private, so I can’t abuse it. Yet it
contains this:

@request.relative_url_root

And now the answer is documented. (-;


Phlip


#5

Heh. I love your attitude. Make fun of me for not Googling when you
didn’t
Google yourself. Sorry I tried to help.

RSL