我的应用程序适用于开发人员,我正在尝试将其部署到新的切片。这种环境被称为“beta”。一切似乎都工作正常,除了rake一直试图传递一个空白的''数据库名称,无论是用capistrano还是手动调用。我真的很感激任何帮助,因为我不知道下一步该做什么。谷歌搜索没有发现任何事情。
谢谢你, Rabbit on Rails
ops@rws:~/sites/darkserve/current$ rake db:drop
(in /home/ops/sites/darkserve/releases/20110218183444)
Couldn't drop : #<ActiveRecord::StatementInvalid: Mysql2::Error: Incorrect database name '': DROP DATABASE IF EXISTS ``>
ops@rws:~/sites/darkserve/current$ rake db:create
(in /home/ops/sites/darkserve/releases/20110218183444)
already exists
* executing "cd /home/ops/sites/darkserve/releases/20110218183444; bundle exec rake RAILS_ENV=beta db:migrate"
servers: ["173.203.106.112"]
[173.203.106.112:30000] executing command
*** [err :: 173.203.106.112:30000] rake aborted!
*** [err :: 173.203.106.112:30000]
*** [err :: 173.203.106.112:30000] Mysql2::Error: No database selected: SHOW TABLES
*** [err :: 173.203.106.112:30000]
*** [err :: 173.203.106.112:30000]
*** [err :: 173.203.106.112:30000] (See full trace by running task with --trace)
*** [err :: 173.203.106.112:30000]
** [out :: 173.203.106.112:30000] (in /home/ops/sites/darkserve/releases/20110218183444)
我已经尝试过按摩我的database.yml和beta.rb文件这些显而易见的事情,但无济于事。 Mysql正常工作,并创建了正确的用户。
common: &mysql
adapter: mysql2
host: localhost
encoding: utf8
username: root
password:
pool: 5
timeout: 5000
reconnect: true
development:
<<: *mysql
database: darkserve_development
test:
<<: *mysql
database: darkserve_test
beta:
<<: *mysql
database: darkserve_beta
production:
<<: *mysql
database: darkserve_prod
ops@rws:~/sites/darkserve/current$ mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 57
Server version: 5.1.41-3ubuntu12.9 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
+--------------------+
2 rows in set (0.00 sec)
mysql>
#beta.rb
Darkserve::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"
# For nginx:
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
# See everything in the log (default is :info)
# config.log_level = :debug
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Use a different cache store in production
#config.cache_store = :mem_cache_store
# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_assets = false
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
config.action_mailer.delivery_method = :smtp
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end
ops@rws:~/sites/darkserve/current$ ruby -v
ruby 1.9.2p136 (2010-12-25 revision 30365) [x86_64-linux]
ops@rws:~/sites/darkserve/current$ rails -v
Rails 3.0.4
ops@rws:~/sites/darkserve/current$ irb
ruby-1.9.2-p136 :001 > require 'mysql'
=> true
答案 0 :(得分:7)
我刚切换到ruby 1.9并发现了同样的错误。我认为这是YAML解析器的一个错误。在扩展引用时似乎无法包含其他键。
考虑以下文件:test.yml
common: &default
user_name: 'test_user'
failed:
<<: *default
database: 'ignored db name'
success:
user_name: 'test_user'
database: 'db name'
现在看看你从ruby提示中获得了什么:
puts YAML.load_file('test.yml').inspect
{"common"=>{"user_name"=>"test_user"}, "failed"=>{"user_name"=>"test_user"},
"success"=>{"user_name"=>"test_user", "database"=>"db name"}}
要解决此问题,请确保boot.rb选择“syck”,我相信它已存在一段时间了。
require 'rubygems'
# Set up gems listed in the Gemfile.
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'yaml'
YAML::ENGINE.yamler= 'syck'
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])