【发布时间】:2012-02-07 08:07:16
【问题描述】:
我是 Rails 新手,遇到了一些问题。 关于系统:Rails-3.2.1 Ruby-1.8.7 RedHat
在本地系统中一切正常。问题发生在网络主机上。 我正在尝试配置系统,但给出的信息不够好。 我正在使用 mysql(mysql2 gem)并且 database.yml 配置正确(我猜)。
database.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
reconnect: false
database: rffaguiar
pool: 5
username: rffaguiar
password: ******
host: mysql01.rffaguiar.com.br
# 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
reconnect: false
database: rffaguiar
pool: 5
username: rffaguiar
password: ******
host: mysql01.rffaguiar.com.br
production:
adapter: mysql2
encoding: utf8
reconnect: false
database: rffaguiar
pool: 5
username: rffaguiar
password: ******
host: mysql01.rffaguiar.com.br
捆绑命令
/home/storage/3/d2/f5/rffaguiar/rails_apps/teste_pos$ bundle
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.0.4)
Using activesupport (3.2.1)
Using builder (3.0.0)
Using activemodel (3.2.1)
Using erubis (2.7.0)
Using journey (1.0.1)
Using rack (1.4.1)
Using rack-cache (1.1)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.1)
Using mime-types (1.17.2)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.1)
Using actionmailer (3.2.1)
Using arel (3.0.0)
Using tzinfo (0.3.31)
Using activerecord (3.2.1)
Using activeresource (3.2.1)
Using bundler (1.0.21)
Using coffee-script-source (1.2.0)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.5)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.1)
Using coffee-rails (3.2.2)
Using johnson (1.2.0)
Using jquery-rails (2.0.0)
Using mysql (2.8.1)
Using mysql2 (0.3.11)
Using rails (3.2.1)
Using sass (3.1.14)
Using sass-rails (3.2.4)
Using uglifier (1.2.3)
[32mYour bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.[0m
测试应用只有 1 个控制器(hello)、1 个视图(索引)和 1 个模型。 当 root 是默认的 rails html 页面时,没关系,但是当我将 root 修改为 'hello#index' 时,我得到 500 错误页面。
我不知道是否有相关的东西,但是当使用“rake test”时,我得到了这个:
无法通过套接字连接到本地 MySQL 服务器 '/var/lib/mysql/mysql.sock'
但是那里没有 mysql.sock。 我一直在寻找有关这些问题的几个小时,但没有成功。 谁能指出我正确的方向?抱歉,如果有什么问题,这是我的第一个问题。
更新 1:
netstat -ln | grep mysql
什么都不返回。
更新 2: 现在,我收到了一个乘客错误页面:
在任何来源中都找不到 rake-0.9.2.2 (Bundler::GemNotFound)
但是 gem 在 Gemfile 上。这是我的虚拟主机提供的用于配置测试的link。忘记葡萄牙语,看代码,=)。在那里,您可以在主机线上看到 IP,而不是像我正在做的主机名,但他们说要使用主机名,因为 DB IP 可以更改。是的,我正在尝试使用两者的所有测试。
关于socket线:我之前遇到mysql报错的时候才用过。现在我删除了它。
关于乘客:我正在使用 restart.txt 重新启动乘客后进行测试
【问题讨论】:
-
你说“database.yml 配置正确(我猜)” - 为什么这是一个猜测?您从哪里获得该配置 - 尤其是
socket行? -
mysql --version 返回:mysql Ver 14.14 Distrib 5.1.54, for unknown-linux-gnu (x86_64) using readline 5.1
-
@Gareth:我从网络主机获得了 database.yml。在“mysql.sock”中给出错误之后,我测试了套接字线。但我测试了有没有它。
-
这就是你的
database.yml的全部内容吗?你有production部分吗? -
能否请您提供您的主机使用的 rake 版本。它似乎。也许你也应该运行“bundle”命令。
标签: ruby-on-rails ruby-on-rails-3