Reputation: 10400
On my server, mysql is running.
$ pgrep mysql
28636
Rails console command works.
anand@app-Staging:~/public_html/app_staging/current$ rails console staging
Loading staging environment (Rails 3.0.19)
irb(main):001:0>
But when i access the app from browser, passenger is throwing this error.
Your application's database configuration file might be written incorrectly. Please check it and fix any errors.
The database server may not be running. Please check whether it's running, and start it if it isn't.
Error message:
production database is not configured (ActiveRecord::AdapterNotSpecified)
Exception class:
ActiveRecord::AdapterNotSpecified
Application root:
/home/anand/public_html/app_staging/current
Here is my apache config
anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging
<VirtualHost *:80>
ServerName myappstaging.org
ServerAlias *.myappstaging.org
DocumentRoot /home/anand/public_html/app_staging/current/public
RailsEnv staging
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]
XSendFile on
</VirtualHost>
Here is my config/database.yml
staging:
adapter: mysql2
encoding: utf8
database: app_staging
username: root
password: xxxxxx
host: localhost
I have restarted mysql and tried. Also restarted apache. I have checked passenger config lines in apache config file.
Nothing works. Am i missing something. Please help.
Upvotes: 1
Views: 2118
Reputation: 10400
I should specify the Rails environment like RackEnv staging
for Rails versions >= 3.x
This config fixed the issue.
anand@app-Staging:/etc/apache2/sites-enabled$ cat app_staging
<VirtualHost *:80>
ServerName myappstaging.org
ServerAlias *.myappstaging.org
DocumentRoot /home/anand/public_html/app_staging/current/public
RackEnv staging
RewriteEngine on
RewriteCond %{REQUEST_METHOD} ^OPTIONS
RewriteRule .* - [R=405,L]
XSendFile on
</VirtualHost>
Upvotes: 1