views:

14

answers:

1

Hi,

How would I access the domain name from Rails inside the environments/deveopment.rb? I want to find out whether or not I am on localhost or a real domain. Thank you!

+1  A: 

The environment files are not processed on every request- only at startup, so there wouldn't be any particular context at the time they are processed. This is really the job for a separate environment instead of having dev do double duty.

If you just want to check against the hostname or something though, you can do something like (assuming you're on a unix-like system):

my_host = `hostname`.chomp

and test against that, which may solve your problem.

x1a4
Can I access it in the Application_helper.rb? I mean the request variable?
tesmar
You should be able to, yes.
x1a4