Question

I have a strange problem.

I have the following database.yml

production:
  adapter: postgresql
  encoding: unicode
  database: MyDB_production
  # For details on connection pooling, see rails configuration guide
  # http://guides.rubyonrails.org/configuring.html#database-pooling
  pool: 5

test:
  adapter: postgresql
  host: localhost
  username: 
  password: 
  database: test        # or whatever the name is
  encoding: UTF8

development:
  adapter: postgresql
  encoding: unicode
  database: MyDB_development
  pool: 5
  username: dazzaroonie
  password:

My environment.rb has:

# Load the Rails application.
require File.expand_path('../application', __FILE__)

ENV['RAILS_ENV'] ||= 'production'

# Initialize the Rails application.
Chatrpix::Application.initialize!

My Passenger VHost is:

<VirtualHost *:80>
 ...
    <Directory /Users/dazzaroonie/Sites/newapp/public>
        AllowOverride all
        Options -MultiViews
        RailsEnv production
    </Directory>

</VirtualHost>

So I should be in production mode yes?

I run rails console and I get:

Loading production environment (Rails 4.1.0)
2.1.0 :001 > 

So, it seems to think it's in production, however, when I run rake db:create it's creating the development database and not the production.

I've been looking at this for hours, and no closer to knowing why ...

I don't have an ENV set using my .bashrc etc ...

So, how does every other part of Rails know I'm using production mode, and yet not rake?

Thanks in advance for any guidance.

Was it helpful?

Solution

I think it's because you set RAILS_ENV after loading application.rb. That could cause confusion in the code. Try setting RAILS_ENV before loading application.rb.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top