Reputation: 19031
I have 4 Rails environments.
Rails are deployed perfectly to staging and production except the fact that production Rails is using staging database instead of production database. What am I doing wrong? What haven't I checked yet? Is there something in Capistrano where database setup is needed?
Here are some things to note.
My config/database.yml
clearly differentiates staging and production databases.
staging:
adapter: mysql2
encoding: utf8
database: some_app
pool: 5
username: some_user
password: some_pass
host: staging.zzzzz.com
port: 1911
production:
adapter: mysql2
encoding: utf8
database: some_app
pool: 5
username: some_user
password: some_pass
host: production.zzzzz.com
port: 1611
Rails environment for production and staging are identical. In other words, config/environments/staging.rb
and config/environments/staging.rb
are identical.
Passenger server in production environment should be running the Rails app in production environment. See the line RailsEnv production
<VirtualHost *:80>
LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2011.12/lib/ruby/gems/1.8/gems/passenger-3.0.11/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.7-2011.12/lib/ruby/gems/1.8/gems/passenger-3.0.11
PassengerRuby /opt/ruby-enterprise-1.8.7-2011.12/bin/ruby
PassengerMaxPoolSize 20
Include conf/rhapcom.conf
Include conf/maintenance.conf
Include conf/redirects.conf
DocumentRoot /var/rails80/current/public
<Directory /var/rails80/current/public>
RailsEnv production
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
Include conf/oldrotw.conf
After some investigation, I found that production app is actually running in integration environment. I checked this through Rails.env
. How do I specify to the production app that it should be running in production
environment?
Upvotes: 1
Views: 1358
Reputation: 6682
Use RackEnv production
to specify production environment.
Also, I can't help but notice this in your config/database.yml
:
staging:
# ...
database: some_app
# ...
production:
# ...
database: some_app
# ...
Both staging and production environments are configured to use the same database.
Rails is using staging database instead of production database.
No, they're both sharing a common database.
I believe you want to do something like this:
staging:
# ...
database: some_app_staging
# ...
production:
# ...
database: some_app_production
# ...
Now there are two distinct databases, each used in their appropriate environment.
Upvotes: 1