local variable or method `config' for main:Object (NameError)

不打扰是莪最后的温柔 提交于 2019-12-05 05:37:40

The article states that you should put some code in:

config/environments/[environment].rb

Where [environment].rb is meant to signify one of the following files:

config/environments/development.rb
config/environments/production.rb
config/environments/test.rb

You could also put the code in config/application.rb if you want the same settings across your different environments.

The lines of code shown start with config.*, and they should be placed inside the Rails.application.configure do block.

config/environment.rb in a typical Rails 4 application is just a require and Rails.application.initialize!, and should not need modification.

If you have config.xxx in environment.rb

delete it and add these into development.rb:

Rails.application.configure do
  config.xxx
end

I have also faced such an error(

NameError: undefined local variable or method `server' for main:Object
        from (irb):1
        from C:/RailsInstaller/Ruby2.2.0/bin/irb:11:in `<main>'),

)

maybe its because I am a Newbie in ruby on rails. hence instead of starting the rails server from direct command line I tried it to start from inside of IRB hence I got that error.

when I came out of IRB and started the server again from CMD it started smoothly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!