【发布时间】:2013-12-03 13:02:41
【问题描述】:
在我的服务器上,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>
这是我的配置/database.yml
staging:
adapter: mysql2
encoding: utf8
database: app_staging
username: root
password: xxxxxx
host: localhost
我已经重启了mysql并试过了。还重新启动了apache。我已经检查了 apache 配置文件中的乘客配置行。
没有任何作用。我是不是错过了什么。请帮忙。
【问题讨论】:
-
错误显示“生产”数据库并且您正在显示“暂存”配置,尝试“bundle exec rails c production”,这应该不起作用。你有生产数据库和配置吗?
-
是的 - 明白了。我应该以不同的方式指定环境
-
你是如何指定环境的?
标签: mysql ruby-on-rails ruby-on-rails-3 passenger