簡體   English   中英

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

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

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項目中,我們使用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

嘗試臨時刪除configatron.rb文件,看看是否有幫助。 錯誤在第2行,因此這就是問題所在。

很難確定是否看不到該文件,但我會嘗試永久修復該文件:

  1. require 'configatron'添加require 'configatron'
  2. 更改行,使其顯示Configatron::Integrations::Rails.init而不是Configatron::Rails.init

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM