mysql - 未配置生产数据库

标签 mysql ruby-on-rails ruby-on-rails-3 passenger

在我的服务器上,mysql 正在运行。

$ pgrep mysql
28636

Rails 控制台命令有效。

anand@app-Staging:~/public_html/app_staging/current$ rails console staging  
Loading staging environment (Rails 3.0.19)
irb(main):001:0>

但是当我从浏览器访问该应用程序时,乘客抛出此错误。

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

这是我的apache配置

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>

这是我的config/database.yml

staging:
  adapter: mysql2
  encoding: utf8
  database: app_staging
  username: root
  password: xxxxxx
  host: localhost

我已经重新启动了 mysql 并尝试了。还重新启动了apache。我检查了 apache 配置文件中的乘客配置行。

没有任何作用。我错过了什么吗?请帮忙。

最佳答案

我应该指定 Rails 环境,例如 RackEnv staging for Rails versions >= 3.x

此配置解决了问题。

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>

关于mysql - 未配置生产数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20351976/

相关文章:

mysql - 嵌入系统的表设计

ruby-on-rails - wicked_pdf 渲染一个很小的 ​​pdf 图像

ruby-on-rails - 如何将链接应用于 HAML 中的多行文本字符串?

php - 通过分组查找最大值

php - 如何从一个表中选择两个不同的列并获取一些 id 两次?

javascript - JQuery Mobile/Rails 4 - 仅对表单禁用 Ajax

ruby-on-rails - Rails 中的 JOIN 与 COALESCE 和 ORDER BY

ruby-on-rails-3 - Rails 3.1 : Engine vs. 可安装的应用程序

mysql - Ruby on Rails :Issue with MySQL lib in Rails 3 Project

php - 切换到学说 : how to realize such query?