Question

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.

No correct solution

OTHER TIPS

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top