简体   繁体   English

使用“轨道生成支架”时出现NoMethodError

[英]NoMethodError when using “rails generate scaffold”

I'm following Michael Hartl's Ruby on Rails Tutorial using nitrous.io. 我正在使用nitroous.io关注Michael Hartl的Ruby on Rails教程。 Right now I'm trying to make use of the scaffold command and it's returning a NoMethodError. 现在,我正在尝试使用scaffold命令,并且返回NoMethodError。 I'm very new to coding so I'm not sure of the cause of the error but here's exactly what's happening: 我是编码的新手,所以我不确定错误的原因,但是这就是正在发生的事情:

~/workspace/rails_projects/demo_app(master)$ rails generate scaffold User name:string email:string
/home/action/workspace/rails_projects/demo_app/config/environments/development.rb:1:in `<top (required)>': undefined method `configure' for #<DemoAppp::Application:0x007fa3572a63e8> (NoMethodError)
        from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
        from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require'
        from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency'
        from /home/action/.gem/ruby/2.1.1/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/engine.rb:590:in `each'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/engine.rb:590:in `block in <class:Engine>'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:30:in `instance_exec'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:30:in `run'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:55:in `block in run_initializers'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:44:in `each'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:44:in `tsort_each_child'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:411:in `call'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `call'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
        from /home/action/.parts/packages/ruby2.1/2.1.1/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/initializable.rb:54:in `run_initializers'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/application.rb:215:in `initialize!'
        from /home/action/workspace/rails_projects/demo_app/config/environment.rb:5:in `<top (required)>'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/application.rb:189:in `require'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/application.rb:189:in `require_environment!'
        from /home/action/.gem/ruby/2.1.1/gems/railties-4.0.5/lib/rails/commands.rb:44:in `<top (required)>'
        from bin/rails:8:in `require'
        from bin/rails:8:in `<main>'

To me it seems like for some reason the path for development.rb is not the right one, but I'm just guessing. 在我看来,出于某种原因,development.rb的路径并不正确,但我只是在猜测。

This can result from namespacing issues in your environment. 这可能是由于环境中的命名空间问题引起的。 Your app is called DemoAppp (note the three "p"s), so ensure that your naming convention adheres to the following: 您的应用程序名为DemoAppp (请注意三个 “ p”),因此请确保您的命名约定遵守以下规定:

# app/config/initializers/development.rb
DemoAppp::Application.configure do

Alternatively , if it's possible that DemoAppp is a misspelling, you may want to replace DemoAppp with DemoApp with two "p"s. 或者 ,如果DemoAppp可能拼写错误,则可能要用两个 “ p”替换DemoApppDemoApp

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

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