mysql - Rails 从 WEBrick 而非 Passenger 连接到 MySQL

标签 mysql ruby-on-rails passenger

我刚刚使用 MySql 创建了一个新的 Rails 4 应用程序,如下所示:

rails new mysqltest -d mysql

并使用正确的凭据修改了 database.yml。

我生成了一个示例 Controller 并更新了根路由的路由。

当我开始在生产中使用 WEBrick 时,

rails s -e production

该网站有效。我看到了索引页。

当我开始使用没有 3000 端口的 Passenger 时,我看到以下错误:

database configuration does not specify adapter (ActiveRecord::AdapterNotSpecified)

Passsenger 在生产环境中运行。

我的数据库.yml

# MySQL.  Versions 4.1 and 5.0 are recommended.
#
# Install the MYSQL driver
#   gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
#   gem 'mysql2'
#
# And be sure to use new-style password hashing:
#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
development:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

production:
  adapter: mysql2
  encoding: utf8
  database: sample
  pool: 5
  username: sample
  password: sample
  socket: /var/run/mysqld/mysqld.sock

最佳答案

我在 database.yml 文件和 apache 配置文件中使用的大小写不同。

两者应该相同。例如。 生产

在 apache 配置中,我给出了 Production。将其更改为 production 后它起作用了。

来源 - https://groups.google.com/forum/#!topic/phusion-passenger/Kr-R0gSw6i8

关于mysql - Rails 从 WEBrick 而非 Passenger 连接到 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19053331/

相关文章:

MYSQL Inner Join 从 ID 中获取多个名称

mysql - 一些流行的基于行和基于列的数据库是什么?

ruby-on-rails - 尝试在 Cucumber 功能中使用 "Examples"部分时解析问题

ruby-on-rails - 未初始化的常量 ApplicationController (NameError) - 应用程序在本地运行良好

ruby-on-rails - 如何强制使用 Apache2 + Rails + Phusion 乘客的 'www' 子域?

MySQL:多个表与一个表具有 FK - 是还是否?

php - 将数据从 MySQL 传输到 JavaScript

ruby-on-rails - "Ago"Ruby/Rails 中的日期/时间函数

ruby-on-rails - 指定格式 : "xml" ignored with render_to_string

ruby-on-rails - 由于 Phusion Passenger 队列阻塞导致 Web 服务负载过重