Environment Variable for Ruby on Rails

J

Jeremy Kemper

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Is there an entry in the request.env hash for the host header?

request.host is the method you're looking for. See the docs for
AbstractRequest for some other convenient methods such as subdomains
and remote_ip (which resolves proxied addresses for you.)

Regards,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDf/0oAQHALep9HFYRAlMCAKCqQrXgwo0xosMZWW7fL9xayTDsRACcCI+N
S8ZDSVQC6Ml01VsPd5NQQfM=
=AxT9
-----END PGP SIGNATURE-----
 
N

Nathaniel S. H. Brown

You can use the magical .inspect on the request.env hash like so:
request.env.inspect to find out anything about the internals of a hash.

script/console will work pretty well for that kind of debugging.

Warmest regards,
Nathan.
 
J

Jeremy Kemper

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Perfect! Unfortunately, I can't seem to find the documentation though
for it?
http://api.rubyonrails.org/classes/ActionController/
AbstractRequest.html
talks about some methods, but not request.host.

An oversight; its documentation is exposed the next release.
The only reason I ask is because now I want to pull back the Session
Id. I don't see a straight-forward way to get it?

In a controller, session.session_id

Please take further discussion to the Rails list. Thanks!

jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (Darwin)

iD8DBQFDgT9TAQHALep9HFYRApKEAJ9w6F2VGfIs3OpceD40GXWGX5rF6wCfa8xG
ic7N65uLC+/5PK/ExtBOqcs=
=rWw6
-----END PGP SIGNATURE-----
 

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

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top