`rails s -e production` loads development database not production

I'm running into a very weird rails server problem.

I started a rails application in production mode with `rails s -e produciton` and got some db errors when visiting the site.

Then I realised that it loaded development database not production database.

To confirm that, I removed development db config from database.yml.

Then I got $ bundle exec rails s -e production Digest::Digest is deprecated; use Digest => Booting Thin => Rails 4.1.6 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Digest::Digest is deprecated; use Digest Exiting /home/ubuntu/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/connection_specification.rb:257:in `resolve_symbol_connection': 'development' database is not configured. Available: ["production", "test"] (ActiveRecord::AdapterNotSpecified)

What happened here?

I don't immediately see why it would be relevant but I would sort the above problem first. It likely means you are using an out of date gem. My principle after decades of tracking down software issues is always to sort problems that should be easily sortable before worrying about more esoteric problems.

Colin

Jiajia Wang wrote in post #1166961:

I'm running into a very weird rails server problem.

I started a rails application in production mode with `rails s -e produciton` and got some db errors when visiting the site.

Have you tried with

$ RAILS_ENV=production bundle exec rails s

instead? Does this yield different results?

Jiajia Wang wrote in post #1166961:

I'm running into a very weird rails server problem.

I started a rails application in production mode with `rails s -e produciton` and got some db errors when visiting the site.

Did you cut-n-paste that command? Because you have misspelt produciton (swapped i and t)

-Rob

Mads Ohm Larsen wrote in post #1167041:

Jiajia Wang wrote in post #1166961:

I'm running into a very weird rails server problem.

I started a rails application in production mode with `rails s -e produciton` and got some db errors when visiting the site.

Have you tried with

$ RAILS_ENV=production bundle exec rails s

instead? Does this yield different results?

Yes, I tried.

It gave the same result.

Rob Biedenharn wrote in post #1167042:

Jiajia Wang wrote in post #1166961:

I'm running into a very weird rails server problem.

I started a rails application in production mode with `rails s -e produciton` and got some db errors when visiting the site.

Then I realised that it loaded development database not production database.

To confirm that, I removed development db config from database.yml.

Then I got $ bundle exec rails s -e production Digest::Digest is deprecated; use Digest => Booting Thin => Rails 4.1.6 application starting in production on http://0.0.0.0:3000 => Run `rails server -h` for more startup options => Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option) => Ctrl-C to shutdown server Digest::Digest is deprecated; use Digest Exiting

/home/ubuntu/.rbenv/versions/2.1.4/lib/ruby/gems/2.1.0/gems/activerecord-4.1.6/lib/active_record/connection_adapters/connection_specification.rb:257:in

`resolve_symbol_connection': 'development' database is not configured. Available: ["production", "test"] (ActiveRecord::AdapterNotSpecified)

What happened here?

Figured out what the problem was.

Found this line in initializers/session_store.rb ActiveRecord::SessionStore::Session.establish_connection(:development)

Removing it and changing session store to use :cookie_store solved the problem.