get app url with rails

This is the root of my app:

http://localhost:3000/management

How can I get this from within rails?

eggie5 wrote:

This is the root of my app:

http://localhost:3000/management

How can I get this from within rails?

@request.relative_url_root

New question - do we need the @?

I wound up using this:

#{request.protocol}#{request.host_with_port}

but thanks for pointing me to the request class

[Please don't top post as it makes the discussion more difficult to follow.]

#{request.protocol}#{request.host_with_port}

Which you could write as

#{ request.protocol + request.host_with_port }

if you cared to. I have a feeling that a lot of people don't realize that #{} can contain an arbitrary expression rather than just a variable name. In this case combining both in one #{} reduces the noise a bit.

Michael Glaesemann
grzm seespotcode net

Yeah, I know about that, I was just in rush.
Thanks