rake db:create给出NoMethodError:Rails:Module的未定义方法`init'

时间:2015-11-19 20:02:10

标签: mysql ruby-on-rails ruby

mysql似乎正在运作 - 我可以

$ mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.27 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 

然而,在rails项目中,我们已经使用了一段时间了:

$ rake db:create
14:47:41 mdurrant EQ-267 /Users/mdurrant/eq/lynx master
$ rake db:migrate
rake aborted!
NoMethodError: undefined method `init' for Rails:Module
/Users/mdurrant/eq/lynx/config/initializers/configatron.rb:2:in `<top (required)>'
/Users/mdurrant/.rvm/gems/ruby-2.1.5/gems/railties-3.2.22/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
/Users/mdurrant/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `eval'
/Users/mdurrant/.rvm/gems/ruby-2.1.5/bin/ruby_executable_hooks:15:in `<main>'
...
$ ruby -v
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin14.0]
14:50:33 mdurrant EQ-267 /Users/mdurrant/eq/lynx master
$

$ cat config/initializers/configatron.rb 
require 'configatron'
Configatron::Rails.init

1 个答案:

答案 0 :(得分:0)

尝试暂时删除configatron.rb文件,看看是否有帮助。错误发生在第2行,所以这就是问题所在。

很难确定没有看到文件,但我会尝试将其永久修复:

  1. require 'configatron'添加到a​​pp.rb
  2. 更改该行,使其显示为Configatron::Integrations::Rails.init,而不是Configatron::Rails.init