Accessing URL/URI information in Rails in the environments file?
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!
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.
精彩评论