Rake db:migrate and script/console in wrong environment

Hi,

I have the production version of my rails site hosted on a server. (I
uncommented the line “ENV[‘RAILS_ENV’] ||= ‘production’” in the
environment.rb file). I know it’s running in production mode because I
can tell that the production database is being used and it’s the
production log that’s being written to.

But, whenever I try to “rake db:migrate” or “script/console”, it’s the
development database that gets migrated and the development
environment that gets loaded into console — unless I specify
“RAILS_ENV=production”.

What’s up with that? I’ve never had that happen before. The hosting
company says it’s nothing in their config (of course), so is there
something in one of my files that could be doing that?

Thanks,
Greg

On Jun 16, 2008, at 12:24 PM, Greg B. wrote:

environment that gets loaded into console — unless I specify
“RAILS_ENV=production”.

What’s up with that? I’ve never had that happen before. The hosting
company says it’s nothing in their config (of course), so is there
something in one of my files that could be doing that?

Thanks,
Greg

You could set RAILS_ENV=production in your login script. What do you
see when you type:

env

into the shell. Does RAILS_ENV have a value? (equivalently: echo
$RAILS_ENV)

Otherwise, you can say:
script/console production
or give the setting with each command as you mentioned.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

RAILS_ENV is not listed when I type “env”. I don’t see anything there
that would force the development environment.

Greg

On Jun 16, 12:41 pm, Rob B. [email protected]

On Jun 16, 2008, at 1:13 PM, Greg B. wrote:

RAILS_ENV is not listed when I type “env”. I don’t see anything there
that would force the development environment.

Greg

The development environment is the default when it isn’t set otherwise.

Chances are that your startup sets RAILS_ENV (to production).

-Rob