Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Rails 3-测试版环境尝试创建/迁移空白数据库名称_Mysql_Ruby On Rails_Ruby On Rails 3 - Fatal编程技术网

Mysql Rails 3-测试版环境尝试创建/迁移空白数据库名称

Mysql Rails 3-测试版环境尝试创建/迁移空白数据库名称,mysql,ruby-on-rails,ruby-on-rails-3,Mysql,Ruby On Rails,Ruby On Rails 3,我的应用程序在dev上运行,我正在尝试将其部署到一个新的切片上。该环境称为“beta”。除了rake一直试图传递一个空的“”数据库名(无论是在capistrano中调用还是手动调用)之外,一切似乎都正常工作。我真的很感激任何帮助,因为我不知道下一步该做什么。在谷歌上搜索,结果一无所获 谢谢,, 铁轨上的兔子 ops@rws:~/sites/darkserve/current$ rake db:drop (in /home/ops/sites/darkserve/releases/20110218

我的应用程序在dev上运行,我正在尝试将其部署到一个新的切片上。该环境称为“beta”。除了rake一直试图传递一个空的“”数据库名(无论是在capistrano中调用还是手动调用)之外,一切似乎都正常工作。我真的很感激任何帮助,因为我不知道下一步该做什么。在谷歌上搜索,结果一无所获

谢谢,, 铁轨上的兔子

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)
ops@rws:~/sites/darkserve/current$rake db:drop
(in/home/ops/sites/darkserve/releases/20110218183444)
无法删除:#
ops@rws:~/sites/darkserve/current$rake db:create
(in/home/ops/sites/darkserve/releases/20110218183444)
已经存在
*执行“cd/home/ops/sites/darkserve/releases/20110218183444;bundle exec rake RAILS_ENV=beta db:migrate”
服务器:[“173.203.106.112”]
[173.203.106.112:30000]正在执行命令
***[错误::173.203.106.112:30000]rake中止!
***[错误::173.203.106.112:30000]
***[err::173.203.106.112:30000]Mysql2::错误:未选择数据库:显示表
***[错误::173.203.106.112:30000]
***[错误::173.203.106.112:30000]
***[错误::173.203.106.112:30000](通过使用--trace运行任务查看完整跟踪)
***[错误::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 
common:&mysql
适配器:mysql2
主机:本地主机
编码:utf8
用户名:root
密码:
游泳池:5
超时:5000
重新连接:正确
发展:

我刚切换到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'
要解决这个问题,请确保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'])

如何设置环境?$cat~/.bash\u profile export RAILS\u ENV=beta加载测试环境(RAILS 3.0.4)ruby-1.9.2-p136:001>RAILS.ENV=>“beta”在database.yml文件中,间距可能是个大问题..检查间距是否正常..我在发布的文件中没有看到任何问题..安装看起来不错。您可以验证
current
是否实际指向正确的版本。是否找到解决此问题的方法?只是不使用公共设置并明确定义所有内容吗?不幸的是,syck在rubygems上不可用,这使得它不容易使用。我相信它包含在您的rails安装中。我不记得安装了什么东西来让它工作。
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'])