Forum: Ruby on Rails get which enviornment is running from controller..

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aaron S. (Guest)
on 2007-07-16 01:00
how can I get what enviornment is currently running from a controller?..
like development, test, production, etc.

thanks..
zaven (Guest)
on 2007-07-16 01:42
(Received via mailing list)
I'd like to know this also.  I need to know how force a rake task to
pick up an environment other than 'production' on my production host.
I renamed my environment to something more specific, but "rake
db:migrate" always uses the configuration under the "production"
environment...

On Jul 15, 2:00 pm, Aaron S. <removed_email_address@domain.invalid>
zaven (Guest)
on 2007-07-16 01:59
(Received via mailing list)
Ah, google actually had the answer to my question:
   rake db:migrate RAILS_ENV=my_production_env
Aaron S. (Guest)
on 2007-07-16 02:03
zaven wrote:
> Ah, google actually had the answer to my question:
>    rake db:migrate RAILS_ENV=my_production_env

I'm looking to find out how you access this in a controller. is it still
RAILS_ENV?
Matthew Rudy J. (Guest)
on 2007-07-16 02:56
if you take a look at your rails gem.
in rails/lib/initializer.rb, line 12-ish,
there's the following;

RAILS_ENV = (ENV['RAILS_ENV'] || 'development').dup unless
defined?(RAILS_ENV)

So,
indeed,
calling RAILS_ENV from anywhere inside you app will return the
environment.

Aaron S. wrote:
> zaven wrote:
>> Ah, google actually had the answer to my question:
>>    rake db:migrate RAILS_ENV=my_production_env
>
> I'm looking to find out how you access this in a controller. is it still
> RAILS_ENV?
This topic is locked and can not be replied to.