【发布时间】:2015-01-23 00:35:13
【问题描述】:
我正在编写一个 Rails 应用程序,我正在尝试使用 Devise。在setup instructions here之后,我正在尝试做rails generate devise:install,但我一直收到这个错误:
~/projects/readone/config/application.rb:8:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
我尝试了不同的方法,例如卸载、重新安装 gem 等。我还在 Google 和 Stack Overflow 上的其他地方发现了一些类似的错误,但没有一个与这个 undefined local variable or method `config' 错误有关。
我将在下面包含完整的错误。知道会发生什么吗?
~/readone/config/application.rb:8:in `<top (required)>': undefined local variable or method `config' for main:Object (NameError)
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:82:in `require'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:82:in `preload'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:143:in `serve'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:131:in `block in run'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:125:in `loop'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application.rb:125:in `run'
from /~/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in `<top (required)>'
from /~/.rbenv/versions/2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /~/.rbenv/versions/2.1.3/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from -e:1:in `<main>'
【问题讨论】:
-
发现问题:我的配置中有一行写着
config.force_ssl = true。将其注释掉,并且有效!考虑删除我的问题,但认为也许其他人可能会在某个时候遇到这个问题。 -
在此处显示代码:
~/readone/config/application.rb:8 -
@МалъСкрылевъ:是的,这就是我在自己的评论中所指的。谢谢!
标签: ruby-on-rails ruby devise undefined