耙子中止未定义的方法“每个”

Posted

技术标签:

【中文标题】耙子中止未定义的方法“每个”【英文标题】:Rake aborted undefined method `each' 【发布时间】:2015-12-04 09:43:19 【问题描述】:

下午好。 无法处理癌症数据库:迁移

user@ubuntu:~/furriery/furriery$ rake db:migrate 耙中止! 未定义的方法each' for "../.openshift/config/database.yml":String /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activerecord-4.1.4/lib/active_record/connection_adapters/connection_specification.rb:163:inresolve_all' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activerecord-4.1.4/lib/active_record/connection_handling.rb:69:in resolve' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activerecord-4.1.4/lib/active_record/core.rb:46:inconfigurations=' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activerecord-4.1.4/lib/active_record/railtie.rb:128:in block (2 levels) in <class:Railtie>' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:38:ininstance_eval' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:38:in execute_hook' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:28:inblock in on_load' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:27:in each' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/lazy_load_hooks.rb:27:inon_load' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activerecord-4.1.4/lib/active_record/railtie.rb:118:in block in <class:Railtie>' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/initializable.rb:30:ininstance_exec' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/initializable.rb:30:in run' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/initializable.rb:55:inblock in run_initializers' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/initializable.rb:54:in run_initializers' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/application.rb:300:ininitialize! /home/user/furriery/furriery/config/environment.rb:5:in <top (required)>' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:inrequire' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in block in require' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:inload_dependency' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:247:in require' /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/application.rb:276:inrequire_environment! /home/user/.rvm/gems/ruby-2.0.0-p643/gems/railties-4.1.4/lib/rails/application.rb:379:in block in run_tasks_blocks' /home/user/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:ineval' /home/user/.rvm/gems/ruby-2.0.0-p643/bin/ruby_executable_hooks:15:in `' 任务:TOP => db:migrate => 环境 (通过使用 --trace 运行任务查看完整跟踪)

ruby 2.0.0p643(2015-02-25 修订版 49749)[i686-linux] 导轨 4.1.4 rvm 1.26.11(最新)作者 Wayne E. Seguin,Michal Papis [https://rvm.io/]

【问题讨论】:

【参考方案1】:

检查您的 database.yml 文件并确保每个“:”分隔符后跟一个空格。还要确保你有空格,而不是制表符,用于缩进。您可以在此处检查您的文件是否是有效的 YAML:http://www.yamllint.com/

【讨论】:

网站yamllint.com检查文件.yml 在线宣誓 (): 在第 27 行第 7 列扫描别名时未找到预期的字母或数字字符

以上是关于耙子中止未定义的方法“每个”的主要内容,如果未能解决你的问题,请参考以下文章

Rake 正在中止,因为 sqlite db 的未定义方法“inet”

类的 Ruby 未定义方法“每个”

Rails 类给出 NoMethodError 未定义的方法“每个”

nil:NilClass 的未定义方法“每个”,但我使用了实例变量

Electron“安装已中止,安装程序未成功地运行完成”

在每个EXISTING属性上获取NoMethodError(未定义的方法)