简体   繁体   English

rake db:create提供了NoMethodError:Rails:Module的未定义方法'init'

[英]rake db:create gives NoMethodError: undefined method `init' for Rails:Module

mysql seems to be working - i can 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> 

However in a rails project we've used ok for a while: 但是在Rails项目中,我们使用ok已有一段时间了:

$ 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

Try to temporarily remove the configatron.rb file and see if that helps. 尝试临时删除configatron.rb文件,看看是否有帮助。 The error is at line 2 so this is where the problem lies. 错误在第2行,因此这就是问题所在。

Hard to be sure without seeing the file but I'd try this to permanently fix it: 很难确定是否看不到该文件,但我会尝试永久修复该文件:

  1. add require 'configatron' to app.rb require 'configatron'添加require 'configatron'
  2. change the line so it says Configatron::Integrations::Rails.init instead of Configatron::Rails.init . 更改行,使其显示Configatron::Integrations::Rails.init而不是Configatron::Rails.init

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM